From d339c8613edc7cc42dd01f6932805038e41c3938 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Thu, 16 Oct 2014 23:15:12 -0700 Subject: [PATCH] GUAC-842: Add onmouseout event to Guacamole.Mouse. Fix GUAC-833 while we're in here. --- .../src/main/webapp/modules/Mouse.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/guacamole-common-js/src/main/webapp/modules/Mouse.js b/guacamole-common-js/src/main/webapp/modules/Mouse.js index 9e7f9e1d1..e3487a77e 100644 --- a/guacamole-common-js/src/main/webapp/modules/Mouse.js +++ b/guacamole-common-js/src/main/webapp/modules/Mouse.js @@ -100,6 +100,14 @@ Guacamole.Mouse = function(element) { */ this.onmousemove = null; + /** + * Fired whenever the mouse leaves the boundaries of the element associated + * with this Guacamole.Mouse. + * + * @event + */ + this.onmouseout = null; + /** * Counter of mouse events to ignore. This decremented by mousemove, and * while non-zero, mouse events will have no effect. @@ -199,7 +207,7 @@ Guacamole.Mouse = function(element) { // Check that mouseout is due to actually LEAVING the element var target = e.relatedTarget || e.toElement; - while (target !== null) { + while (target) { if (target === element) return; target = target.parentNode; @@ -220,6 +228,10 @@ Guacamole.Mouse = function(element) { guac_mouse.onmouseup(guac_mouse.currentState); } + // Fire onmouseout event + if (guac_mouse.onmouseout) + guac_mouse.onmouseout(); + }, false); // Override selection on mouse event element.