Disable WebView touch events in Android

mWebView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); Disables all touch events on a WebView because the touch listener is executed before the default touch behavior of the WebView. By returning true the event is consumed and isn’t propagated to the WebView. Using android:clickable=”false” does not disable touch … Read more

Click event called twice on touchend in iPad

iPad both understands touchstart/-end and mousestart/-end. Is gets fired like this: ┌─────────────────────┬──────────────────────┬─────────────────────────┐ │Finger enters tablet │ Finger leaves tablet │ Small delay after leave │ ├─────────────────────┼──────────────────────┼─────────────────────────┤ │touchstart │ touchend │ mousedown │ │ │ │ mouseup │ └─────────────────────┴──────────────────────┴─────────────────────────┘ You have to detect if the user is on a tablet and then relay on the touch … Read more

How to remove an event listener in javascript?

Put the listener as a variable and attach via .addEventListener var myListener = function (e) { closePopupOnClick(e, popup); }; document.addEventListener(‘touchstart’, myListener, true); then pass it again when removing with .removeEventListener document.removeEventListener(‘touchstart’, myListener); If you’re not in strict mode you can make a listener remove itself with arguments.callee document.addEventListener(‘touchstart’, function (e) { closePopupOnClick(e, popup); document.removeEventListener(‘touchstart’, arguments.callee); … Read more

How to determine if the client is a touch device [duplicate]

You can use the following JS function: function isTouchDevice() { var el = document.createElement(‘div’); el.setAttribute(‘ongesturestart’, ‘return;’); // or try “ontouchstart” return typeof el.ongesturestart === “function”; } Source: Detecting touch-based browsing. Please note the above code only tests if the browser has support for touch, not the device. Related links: How to detect a mobile device … Read more

How to get a CGPoint from a tapped location?

you have two way … 1. -(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [[event allTouches] anyObject]; CGPoint location = [touch locationInView:touch.view]; } here,you can get location with point from current view… 2. UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapped:)]; [tapRecognizer setNumberOfTapsRequired:1]; [tapRecognizer setDelegate:self]; [self.view addGestureRecognizer:tapRecognizer]; here,this code use when you want to do … Read more

Understanding touch events

If you haven’t already, I would suggest reading the source code for Hammer.js https://github.com/hammerjs/hammer.js/blob/master/hammer.js Between comments and code it’s about 1400 lines, there is great documentation and the code is easy to understand. You can see how the author has chosen to solve a lot of the common touch events: hold, tap, doubletap, drag, dragstart, … Read more

Android ACTION_MOVE Threshold

I agree in part with the post by @passsy but come to a different conclusion. Firstly as mentioned, the mTouchSlop is the value that we are interested in and is exposed via ViewConfiguration.get(context).getScaledTouchSlop(); If you check the Android source for the ViewConfiguraton, the default value for TOUCH_SLOP is 8dip, but the comments mention that this … Read more

How to programmatically trigger the touch event in android?

// Obtain MotionEvent object long downTime = SystemClock.uptimeMillis(); long eventTime = SystemClock.uptimeMillis() + 100; float x = 0.0f; float y = 0.0f; // List of meta states found here: developer.android.com/reference/android/view/KeyEvent.html#getMetaState() int metaState = 0; MotionEvent motionEvent = MotionEvent.obtain( downTime, eventTime, MotionEvent.ACTION_UP, x, y, metaState ); // Dispatch touch event to view view.dispatchTouchEvent(motionEvent);

tech