Release mouse buttons if mouse leaves browser window.
[guacamole-common-js.git] / src / main / resources / mouse.js
index 6f422d2..fb86005 100644 (file)
@@ -112,6 +112,21 @@ function GuacamoleMouse(element) {
         buttonReleasedHandler(getMouseState(0, 0));
     };
 
+    element.onmouseout = function(e) {
+
+        e.stopPropagation();
+
+        // Release all buttons
+        if (mouseLeftButton || mouseMiddleButton || mouseRightButton) {
+            mouseLeftButton = 0;
+            mouseMiddleButton = 0;
+            mouseRightButton = 0;
+
+            buttonReleasedHandler(getMouseState(0, 0));
+        }
+
+    };
+
     // Override selection on mouse event element.
     element.onselectstart = function() {
         return false;