View Full Version : Mouse Buttons: Firefox really sucks !!!
hymanroth
09-13-2006, 03:35 PM
Perhaps it's W3C's fault - but anyway mouse button detection under FF is terrible.
Basically, event.button is set to zero if no button is pressed AND ALSO if the left button is pressed.
This makes it impossible to check if the left button is STILL DOWN.
Say you have a drag and drop routine and drag an object (or at least the mouse pointer) out of the browser window, and then release the left mouse button.
Because the event happens outside the browser window, mouseup won't fire (it does under IE). So if you drag the pointer back inside the browser window there is NO WAY of knowing if the left button has been released.
In IE, you can at least use mousemove's event object to check whether the button =1, but in FF it returns zero both for left button and no button!
I can see no way out of this.
Try walterzorn's excellent drag and drop at www.walterzorn.com. Take the mouse pointer to the top of the screen under FF,release the mouse button and then go back into the browser window. Result? The script still thinks the mouse button is pressed....
If anyone knows a way round this, I would be mightily impressed...
liorean
09-15-2006, 03:14 PM
Maybe the moz guys can fix this, if nothing else then by always firing the mouseup event on mouse pointer leaving the application window. So, file the bug in bugzilla.
AFAIK, event.button is only assigned for mouse clicking-related events. You might just want to attach onmouseout to the ownerDocument and kill the dragging routine, just to avoid the situation entirely. Also, try attaching the mouseup to the window object instead - maybe some event voodoo will pull through for you.
hymanroth
09-18-2006, 11:19 AM
Thanks guys. Unfortunately, I can't use either of your suggestions.
This is because my drag and drop scrolls the document window up when the mouse pointer goes off the top of the window (and scrolls down when it goes off the bottom).
If I killed the d+d routine when the mouse pointer left the window, I'd lose the possibility to drag and scroll which is crucial.
Thanks for your replies, though.
I've looked at the mozilla website, but can find no way of reporting bugs.
Any tips?
hymanroth
09-18-2006, 11:39 AM
AFAIK, event.button is only assigned for mouse clicking-related events.....
Just for the record,
event.button always mirrors the actual state of the mouse buttons, even if the event isn't fired by a button-related action.
Try writing a simple onmouseover or onmousemove routine, you'll see that the button property is correctly set.
The underlying problem is the W3C's completely inexplicable use of zero for both no-button and left-button!
liorean
09-18-2006, 05:14 PM
W3C didn't make no-button-press set button to 0 - they didn't define any behaviour for that property for non-button-press events at all. See Document Object Model Events : Interface MouseEvent (http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-MouseEvent)button of type unsigned short, readonly
During mouse events caused by the depression or release of a mouse button, button is used to indicate which mouse button changed state. The values for button range from zero to indicate the left button of the mouse, one to indicate the middle button if present, and two to indicate the right button. For mice configured for left handed use in which the button actions are reversed the values are instead read from right to left.See, the behaviour isn't defined for non-button-click events. That it happens to be 0 is probably just because it's good programming to null out variables before they may come into use. W3C DOM events provide the Event.type property to determine if the event is of a type that is triggered by a button-press, and provides UIEvent.detail to tell you whether a button is pressed or not, see:The detail attribute inherited from UIEvent indicates the number of times a mouse button has been pressed and released over the same screen location during a user action. The attribute value is 1 when the user begins this action and increments by 1 for each full sequence of pressing and releasing. If the user moves the mouse between the mousedown and mouseup the value will be set to 0, indicating that no click is occurring.
Now, I don't know if browsers implement that correctly or not...
hymanroth
09-18-2006, 05:38 PM
There's a lot of interesting stuff there, I'll take a look and let you know if I get anywhere.
Thanks.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.