emulating touch events for Chrome - is there a better way? - ios

I'm using Chrome with source maps for debugging a GWT-based app. It's very nice. What I want to do now is have Chrome pretend to be a mobile device. I turned on "emulate touch events", but it seems that the mouse events are still being generated as well. What I was hoping for would be that the browser would act more or less exactly like a mobile browser. I can run my code in XCode's iOS simulator, but can't debug it easily. Thoughts? Thanks.

Are you sure that a real touch device doesn't also send mouse events when a touch occurs?
If you test this, I'm certain you'll find that a real touch device actually generates some mouse events when a tap or touch start/move/end occurs. Take a look at https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Events/Touch_events to see how to avoid generating mouse events, at least on real touch devices... it may not work in chrome, but you have to at least start there.

Related

Automatic hover triggered on element with FastClick like implementation on iOS 8.1

I have created a simple FastClick implementation. Issue I will be describing occurs with FastClick but since it seems more like a browser bug, i decided to create non-FastClick version to represent the issue.
https://jsbin.com/fofaxiniya/1
Test this on iOS device or simulator running iOS 8.1 or up.
Scenario:
at least iOS 8.1 or up
A simple page with two buttons with active and hover states.
touchend handler that creates a synthetic click event and disables the original click event.
Steps to reproduce:
On the device or simulator,
Click on the first button
Click on the second button that removes itself from DOM on click
The hover state of first button gets triggered.
Why is this annoying?
Because of this weird behaviour, combination of FastClick and Single page application leads to some button randomly being hovered on navigation. Which is definitely unwanted behavior.
I am already considering removing all the hover styles from touch devices. But if I could actually target the problem itself, which is getting rid of the random hover from happenning, that would be great.
Any attempt to shed some light on this will be highly appreciated. :)

On iphone, safari, when typing in an input, the screen goes white

I've tested this on every other browser, it's only on iphone on safari where this is happening. I've built a site on wordpress and whenever a comment field is clicked on a comment, the screen goes white briefly. Cna someone point me in the right direction on how to diagnose this? Thanks!
http://texas-coffee-school.steadfastlight.com/is-inconsistency-killing-your-coffee-business-from-within/#comments To see. Thanks!
Found the answer: By applying position: relative on all the form objects, this fixes the issue iOS was having with the form fields.
Try pressing F12 on Google Chrome for developer tools and emulate the device (by clicking the phone icon and selecting the device required) that is causing the problems (e.g. Apple iPhone6), run the console while leaving a comment and it should display whatever Javascript is running in the background and debug from there.

Delphi - identify mouse click source (hardware vs virtual click)

This time something what I had troubles to find title for...
I'm using windows hooks ( TMOUSEHOOKSTRUCT ~ WH_MOUSE ) to follow mouse movements and mouse button clicks...
This all works fine, however, I want to know whether is there a way to determine the mouse move/click source?
Either if it's possible to identify it by either device ID, or maybe source type (mouse, trackball, touchscreen...), or at least if it was sent from hardware source at all (aka, was it hardware or some mouse recorder macro, or other app's "SetCursor" procedure).
The main goal I'm looking for here is to find a way to block the ability to use mouse recorder to make clicks inside my app (so while in focus, I'd start a mouse hook and in case the move / click was made by software, I'd ignore any actions made..)
This could be asked as "How to block mouse recorder macros in my app" but I'd rather see an actual solution to identify the source as well (and as primary answer), as it might have other uses too.
Thanks.
Edit:
One way would be to check whether the mouse movement was made on snap or slowly (like actually moving the mouse). However, here then the problem persists with touchscreens.
Though, on the other hand - Windows does detect when touch was used (cursor is changed for the dot onscreen), so there surely is a way to at least separate mouse from touch events -> and knowing that would already solve a lot, combined to decline snap-actions on mouse only...
Raymond Chen summed it up in this blog post
There's no point discussing the possibility that the sender of the message is playing tricks and lying to you because (1) your program should just go along with the ruse and respond to fake [menu] messages as if they were real [menu] messages, because (2) there's no way to tell that you're being lied to anyway.
And this blog post of his shows that all input ultimately goes through the same queue, so even Windows does not know the difference between real input and simulated input.
You should look into using the Raw Input API to receive WM_INPUT messages directly from hardware. SetCursor(), SendInput(), macro players, etc cannot simulate those messages. And you would be able to differentiate between input from different devices, but not necessary the type of mouse if multiple mouse devices are being used. Although, since a trackball might have more capabilities than a standard mouse, it might represent itself as a HID device instead of a mouse device.
As for touchscreens, that type of input generates WM_TOUCH messages, which cannot be simulated, either.
So, between WM_INPUT and WM_TOUCH, you can differentiate between hardware mouse input and touchscreen input, at least. Beyond that, simulated input is going to generate standard WM_MOUSE... and WM_(L|M|R|X)BUTTON... messages, which cannot differentiate between hardware input and simulated input, not even in lower-level mouse hooks. You would probably need to keep track of the WM_INPUT/WM_TOUCH messages and match them up to the other messages, and if you cannot find a match then assume input is being simulated.

Separate mouse for debugger

I am programming a Delphi (XE3) application where mouse position is important, but I would like to be able with another mouse to be able to set breakpoints without moving the primary mouse position. I may be pressing shift or control in the application I am trying to debug, so alt-tabbing to the IDE and setting a breakpoint with the keyboard keyboard won't work. Can Windows 7 easily be set up to do this?
It's possible to attach multiple keyboards and mice to a computer, and various video games can take advantage of the multiple input devices, but the OS in general does not take advantage of that. No matter how many keyboards and mice you attach, there's still just one input queue and one cursor on the screen.
If all you need is to set breakpoints without moving the mouse, then you can navigate the input caret to the desired line with the keyboard and then press F5 to toggle breakpoints.
If you need to be able to debug without interfering with the program at all, then you might need to use remote debugging. Although the documentation suggests using Remote Desktop to operate the remote program while you're sitting at the local system, that's not what you want to do in this situation because you'll still have just one set of input devices. Instead, log on to the remote computer from elsewhere (either directly, or via Remote Desktop on a third computer). It'll help to have two computers you can access from the same chair.

Using touch events instead of mouse events on Safari, Firefox and Chrome

Is there a way/addon/extension that simulates the mobile events (touchstart, touchmove, touchend) instead of the normal mouseevents when navigating with Safari, Firefox or Chrome?
I'm trying to test some websites on iPad. If there is a iPad Emulator desktop software, would be great also, but I need some kind of Firebuging.
Thanks!
CaioToOn!
You realize there is in fact an iPad simulator, which you get when you install Xcode? (Which is free, sign up at developer.apple.com.)
Try Phantom Limb
http://www.vodori.com/blog/phantom-limb.html
You should have a look at the tom robinson's virtual light table. It includes a small but working mobile events emulator in javascript.
You can test touch input directly in your browser.
In Firefox or Chrome press Ctrl+Shift+m, which gives you a mobile view of your webpage. There you can also check if the scaling is correct.
There is a button, that lets you simulate touch events instead of mouse events.
For further information look at the chrome device mode.

Resources