The release of PhoneGap-webOS 1.0.0rc1 adds built-in support for touch events. The touch events use the thumbs.js library which has been rolled into PhoneGap-webOS.
To use the touch events in PhoneGap-webOS add the following lines of code to your HTML file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | <html> <head> <script type="text/javascript" src="phonegap.js"></script> </head> <body> <button id="btnTouchStart">Touch Start</button> <script> document.addEventListener('deviceready', function () { // PhoneGap is ready, do all your stuf here }, false); document.querySelector('#btnTouchStart').addEventListener('touchstart', onTouchEvent, false); function onTouchEvent(event) { navigator.notification.alert(event.type); } </script> </body> </html> |
This will create a button and attach an event listener for a ‘touchstart’ event being triggered from the button. The onTouchEvent method will simple display a notification with the event type being handled.
Full source code with examples of all touch & mouse events can be found here.