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

Android: Creating shaped button

I use a crapload of irregular shaped buttons on my app, and to change the “hot zone” or “clickable area” of the button, I just use the Bitmap.getPixel() method to check for alpha on the image used. If the method returns 0, then don’t perform click event. Example: (1) Create your button as usual, whichever … Read more

Recognize touch as MouseDown event

Thanks @PiotrWolkowski You were correct about the way i should follow… Some other issues appear, but i solved the initial problem overriding the WndProc as showed in the following: protected override void WndProc(ref Message m) { switch (m.Msg) { case Win32.WM_POINTERDOWN: case Win32.WM_POINTERUP: case Win32.WM_POINTERUPDATE: case Win32.WM_POINTERCAPTURECHANGED: break; default: base.WndProc(ref m); return; } int pointerID … Read more

manually trigger touch event

According to W3C var e = document.createEvent(‘TouchEvent’); Then, also change e.initMouseEvent(); to e.initTouchEvent(); As you’ve created a touchstart event. The W3C link says: Some user agents implement an initTouchEvent method as part of the TouchEvent interface. When this method is available, scripts can use it to initialize the properties of a TouchEvent object, including its … Read more