StewartMeyers
asked on
Detecting mouse button state in JavaScript
I have implemented a form of drag and drop in JavaScript using mousedown, mouseup, and mousemove handlers. I am attaching these events to document.body. The problem is when the mouse is released outside the browser window that contains the mouse handlers; the mouseup event does not fire in this case. When the mouse is then moved back over the browser window that contains the mouse handlers, the application doesn't know the mouse was released.
In IE, I was able to detect whether the mouse button state changed using the event.button property, but this does not work in Firefox. Anyone know a way to detect the mouse button state in Firefox? How do you handle this situation?
In IE, I was able to detect whether the mouse button state changed using the event.button property, but this does not work in Firefox. Anyone know a way to detect the mouse button state in Firefox? How do you handle this situation?
take a look at this :
http://forums.mozillazine.org/viewtopic.php?p=3272197&sid=4da345f145dbbddedf520cb7d2e0e18c
http://codingforums.com/showthread.php?t=24106
i have no idea in JS but that's what i found .
http://forums.mozillazine.org/viewtopic.php?p=3272197&sid=4da345f145dbbddedf520cb7d2e0e18c
http://codingforums.com/showthread.php?t=24106
i have no idea in JS but that's what i found .
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank's much! The real problem was that I was attaching the mouse events to document.body instead of document, otherwise our solutions were similar. The solution you pointed me to should add an event.button check for IE on the mousemove event, so that when the mouse is moved outside, then back over the browser window, a check can be done to see if the mouse button was released outside the browser window, and if so, dragging should be stopped.
So - the verdict is - it is possible to acomplish - I will try to look into how...