From cab775d7ac6d9736e45da24969d12497ae742fee Mon Sep 17 00:00:00 2001 From: jalf Date: Tue, 22 Jan 2013 12:51:23 +0100 Subject: [PATCH] Register onmouseup events if they occur outside canvas Pressing an holding a mouse button and then moving the mouse out of the canvas before releasing meant that onmouseup was never triggered. --- include/input.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/include/input.js b/include/input.js index fef21634..1cd548a1 100644 --- a/include/input.js +++ b/include/input.js @@ -609,12 +609,13 @@ that.grab = function() { if ('ontouchstart' in document.documentElement) { Util.addEvent(c, 'touchstart', onMouseDown); - Util.addEvent(c, 'touchend', onMouseUp); + Util.addEvent(window, 'touchend', onMouseUp); Util.addEvent(c, 'touchmove', onMouseMove); } else { Util.addEvent(c, 'mousedown', onMouseDown); - Util.addEvent(c, 'mouseup', onMouseUp); + Util.addEvent(window, 'mouseup', onMouseUp); Util.addEvent(c, 'mousemove', onMouseMove); + Util.addEvent(c, 'mouseout', onMouseMove); Util.addEvent(c, (Util.Engine.gecko) ? 'DOMMouseScroll' : 'mousewheel', onMouseWheel); } @@ -632,12 +633,13 @@ that.ungrab = function() { if ('ontouchstart' in document.documentElement) { Util.removeEvent(c, 'touchstart', onMouseDown); - Util.removeEvent(c, 'touchend', onMouseUp); + Util.removeEvent(window, 'touchend', onMouseUp); Util.removeEvent(c, 'touchmove', onMouseMove); } else { Util.removeEvent(c, 'mousedown', onMouseDown); - Util.removeEvent(c, 'mouseup', onMouseUp); + Util.removeEvent(window, 'mouseup', onMouseUp); Util.removeEvent(c, 'mousemove', onMouseMove); + Util.removeEvent(c, 'mouseout', onMouseUp); Util.removeEvent(c, (Util.Engine.gecko) ? 'DOMMouseScroll' : 'mousewheel', onMouseWheel); }