How to use touch event to instead of click event on mobile website - iphone

It seems that click event have delay on website on iphone, but the touchstart or touchend could response correctly, but how to use the only touchstart, touchend and touchmove to simulate click event? or even simulate the long press event on a website on iphone?
I think I can't bind the click handler directly to the touchstart or touchend event, one situation is that when the user press on the screen , fire the touchstart event , but if he don't want a click event, how can he cancel it, either I can't bind the handler to the touchend event.
So how can I simulate the click event with touchstart and touchend event?Is there conflict or something should I mentioned?Is there some post or article talk about how can I achieve this?

I just made a chrome extension for this purpose. It translate mousedown, mousemove, mouseup events to touchstart, touchmove, touchend. It actually simulate iphone5.
https://chrome.google.com/webstore/detail/touchphone-simulator/jijkpkhmnpbecppjhicgegndbbgfnngf
I use phantom-limbs.js. If you want more functions like gesture(which i excluded in my extension), visit brian's github.
https://github.com/brian-c/phantom-limb

Related

How to get Notify of Input Mouse Released when using GameplayCueNotify_Looping

I have been working on a project based on Lyra Framework and am currently trying to implement a Weapon Ability: Charge_Ability - like Halo energy pistol. Here is my issue:
In the GCNL, I am attempting to Bind the OnReleased Mouse Click Event to the OnLoopingStart. Doing so, I expect the OnReleased Mouse Click Event to be fired when the input broadcast its message so I can release my “Charge Ability Bolt Fx”.
However, when running debug printString, the OnLoopingStart is never called. Only the OnRecurring Event is fire.
How can I properly register the OnRelease Event from the GCNL to retrieve input released from mouse click?
Thanks!

Tracing an event in Chrome Devtools

I have an HTML5 web-app and "something" attached a click handler to one of my divs.
If I use the Event Listeners tab I can see the click event and all of its properties - but is there any way to break when an event is fired and trace what is executed? That may give me more information on what attached it.
Disregard, found it:
https://developers.google.com/chrome-developer-tools/docs/javascript-debugging#breakpoints-on-javascript-event-listeners
Simply go into Event Listener Breakpoints under the Sources tab and turn on Mouse > click

ItemClickListener kicking off while ItemLongClickListener happens

The best way I can describe this is the following. I have a poster gallery that has a bunch of images. The selected poster gets highlighted as the user moves back and forth through the gallery. I have the following code set on the poster gallery:
Gallery posterGallery = (Gallery) context.findViewById(R.id.moviePosterGallery);
posterGallery.setAdapter(new MoviePosterImageGalleryAdapter(context, key,
item.getCategory()));
posterGallery.setOnItemSelectedListener(
new MoviePosterOnItemSelectedListener(bgLayout, context));
posterGallery.setOnItemClickListener(new MoviePosterOnItemClickListener());
posterGallery.setOnItemLongClickListener(new MoviePosterOnItemLongClickListener());
What seems to happen is if you press the Remote on the vizio costar, both the Click and Long click events are being fired if you hold down the OK button. As in my case a dialog pops up when a Long click is received, but also the poster launches the video related to that to start playing which is part of the ItemClickListener code..
When testing the same code on a Nexus 7 tablet, only the long click is fired, not both. Is there a way to handle the long click correctly on Google TV. I'm using a vizio costar with Google TV 3 if that helps.
Also, if you move the mouse pointer over the item, and then hold down the - key on the front of the remote, only the long click event is triggered. It just seems to be related to the OK and how long that held down.
I looked at the following similar issue:
onListItemClick and onItemLongClick Google TV
but I already have the onItemLongClick returning true when it handles the event.
There is a quirk with the Vizio remotes. The OK button is not mapped to the right keycode. The Vizio remote sends KEYCODE_ENTER when OK is pressed when in fact it should be sending KEYCODE_DPAD_CENTER. This is what is causing your issue I think. If you try using AbleRemote as the input device you should be able to see it working as expected. Now to solve your issue you may have to go to a keycode listener if a keyboard is present and detect the key events on the posterGallery to fire off short and long clicks.

Why the OnBeforeUnload doesn't intercept the back button in my GWT app?

I have a hook on the beforeUnload event. If i try to click on a link, reload or close the tab or the navigator, the app ask for confirmation before leaving. That's the desired behavior.
But if click on the back button or the backspace outside an input, no confirmation.
At the beginning of the html :
window.onbeforeunload = function() {
if (confirmEnabled)
return "";
}
And i use the Gwt PlaceHistoryMapper.
What did i miss ? Where did i forgot to look ?
Thanks !
As long as you stay within your app, because it's a single-page app, it doesn't by definition unload, so there's no beforeunload event.
When using Places, the equivalent is the PlaceChangeRequestEvent dispatched by the PlaceController on the EventBus. This event is also dispatched in beforeunload BTW, and is the basis for the mayStop() handling in Activities.
Outside GWT, in the JS world, an equivalent would be hashchange and/or popstate, depending on your PlaceHistoryHandler.Historian implementation (the default one uses History.newItem(), so that would be hashchange).

How to press a button with java-script event inside a web-page by code for iOS (iPhone)?

I am writing an application for iOS (iPhone).
How to press a button with java-script event inside a web-page? I need to write a code to press this button. Then the event will be executed. And I'll take result of it's work.
Thanks a lot for help!
You can use:
document.getElementById('id-of-button').click();
This will perform a click event on the button.
EDIT: to run JavaScript in a UIWebView use the stringByEvaluatingJavaScript: method. Eg:
[webView stringByEvaluatingJavaScript:#"document.getElementById('id-of-button').click();"];