Handle events via addEventListener(). This solves an issue with touch events firing...
authorMichael Jumper <zhangmaike@users.sourceforge.net>
Wed, 25 Jan 2012 06:56:53 +0000 (22:56 -0800)
committerMichael Jumper <zhangmaike@users.sourceforge.net>
Wed, 25 Jan 2012 06:56:53 +0000 (22:56 -0800)
src/main/resources/oskeyboard.js

index 8fc3b36..d940a9f 100644 (file)
@@ -266,8 +266,7 @@ Guacamole.OnScreenKeyboard = function(url) {
                     row.appendChild(key_container_element);
 
                     // Set up click handler for key
-                    key_element.onmousedown  =
-                    key_element.ontouchstart = function() {
+                    function press(e) {
 
                         // Press key if not yet pressed
                         if (!key.pressed) {
@@ -306,11 +305,14 @@ Guacamole.OnScreenKeyboard = function(url) {
 
                         }
 
+                        e.preventDefault();
+
                     };
 
-                    key_element.onmouseup  =
-                    key_element.onmouseout =
-                    key_element.ontouchend = function() {
+                    key_element.addEventListener("mousedown", press, true);
+                    key_element.addEventListener("touchstart", press, true);
+
+                    function release(e) {
 
                         // Release key if currently pressed
                         if (key.pressed) {
@@ -329,8 +331,14 @@ Guacamole.OnScreenKeyboard = function(url) {
 
                         }
 
+                        e.preventDefault();
+
                     };
 
+                    key_element.addEventListener("mouseup", release, true);
+                    key_element.addEventListener("mouseout", release, true);
+                    key_element.addEventListener("touchend", release, true);
+
                 }
                 
             });