Change 20100430-maxcarlson-O by [email protected] on 2010-04-30 18:15:26 PDT in /Users/maxcarlson/openlaszlo/trunk-clean for http://svn.openlaszlo.org/openlaszlo/trunk
Summary: UPDATED: Add support for touch devices Bugs Fixed: LPP-8904 - Support touch and gesture events Technical Reviewer: ptw QA Reviewer: hminsky Details: Updated to address Tucker's comments: 1) a) LzSprite#1534, ff. It seems to me that if you get a multi-touch gesture (touches.length > 1) you want to _not_ prevent the default, and return `true` so that the browser will implement the default behavior (e.g., scroll or zoom) and that this should happen before we simulate mouseover and mousemove. Done, but it doesn't seem to help much because all gestures start with a single finger - at least, I wasn't able to reliably put down two fingers at the same time. b) Similarly, for touchend if (touches.length > 0), which would mean that you lifted some fingers from a multi-touch. Another way of looking at it is that we only want to simulate the mouse on single-finger gestures. Done. c) Similarly for LzMouseKernel 2) Why no handling of touchstart in LzMouseKernel? I'm handling this now. 3) The way I read the documentation, you should look at changedTouches to get the position for a touchmove. Since we always want to pay attention to the position of the first finger, we use touches. http://www.sitepen.com/blog/2008/07/10/touching-and-gesturing-on-the-iphone/ helped clarify this for me. 4) Don't we need to similarly fetch the position of the correct touch for the other simulated mouse events? I.e., do we expect to know the coordinates of over/down/up/out/click? The only reliable way I could find to get the position was using event.touches[0].pageX/Y. Comments: 1) Overall this seems like a step in the right direction. I can fiddle with LzPix, drag pictures, move the slider, etc. w00t! 2) Dragging is rather jerky and slow. I wonder if there is anything we can do to optimize that? Yeah :(. I'm not sure why that is, but a drag kernel would be pretty cool, at least for views that didn't have x/y dependencies... 3) Somehow I managed to start drawing a group-select rectangle in LzPix and never could get rid of it. Every time I dragged after that, it would make a new group selection, but I couldn't do anything with it. This should be fixed. 4) I expected to still be able to pinch-zoom over the app, and I can't seem to. Perhaps that is related to issue #1? At this point, I'm not calling preventDefault() at all now - just returning false seems to be enough, at least on the iPad. I can pinch/zoom on parts of the app that aren't clickable (the blue bar at the top) just not on the white region where the photos display. Returning false for the first finger seems to be enough to prevent the pinch/zoom gesture from happening... Otherwise: LzSprite - Add touchevents capability, set to true for iphone/android. Reorganize __setClickable() to register/unregister for touchstart/move/end events when capabilities.touchevents is true, clean up IE-specific event registration. Change globally-used __clickDispatcher() to return the result from __mouseEvent(), which does the actual event processing. __mouseEvent() sends onmousedown/over/up/out/click events for touchevents. LzMouseKernel - When touchevents are available, listen for global touchend events, and look at the position of the first finger to find the global mouse position. Tests: LzPix dhtml now allows dragging on iPad, iPhone, Android and runs as before in Safari and other browsers. Files: M WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js M WEB-INF/lps/lfc/kernel/dhtml/LzMouseKernel.js Changeset: http://svn.openlaszlo.org/openlaszlo/patches/20100430-maxcarlson-O.tar
