Dispatch mouse events for X1 / X2 mouse buttons, and implement back/forward navigation as the default action
Categories
(Core :: DOM: Events, enhancement, P3)
Tracking
()
People
(Reporter: mstange, Unassigned)
Details
Attachments
(1 file, 1 obsolete file)
|
3.10 KB,
text/html
|
Details |
The current implementation of X1 / X2 mouse button clicks skips the mouse event dispatch entirely, and dispatches a WindowCommandEvent instead.
This means that web pages do not have the ability to handle these mouse buttons.
In Chrome, at least on macOS, web pages receive mouse events for X1 / X2 mouse buttons. It seems like back/forward navigation is handled as the default handling for the click event (but this should be investigated some more).
I think we should do the same, where possible. For example, on Windows, it looks like back/forward navigation from these buttons is done via a WM_APPCOMMAND message, and depending on the driver, this message is only sent based on the status we return for the WM_(NC)XBUTTONDOWN/UP messages.
Comment 1•5 years ago
|
||
IIRC, both Microsoft and Logitech interupt the button messages before focused app... I'll check it later.
| Reporter | ||
Comment 2•5 years ago
|
||
| Reporter | ||
Comment 3•5 years ago
|
||
(In reply to Markus Stange [:mstange] from comment #0)
It seems like back/forward navigation is handled as the default handling for the click event (but this should be investigated some more).
The testcase shows that there is no click event; in Chrome, the navigation is done as the default handling of the mouseup event. Calling preventDefault() on mouseup prevents the navigation.
Comment 4•5 years ago
|
||
(In reply to Masayuki Nakano [:masayuki] (he/him)(JST, +0900) from comment #1)
IIRC, both Microsoft and Logitech interupt the button messages before focused app... I'll check it later.
No problem about Logitech's mouse. I'll check Microsoft's mouse tomorrow.
Comment 5•5 years ago
|
||
click is for the primary button only. auxclick is for other buttons.
| Reporter | ||
Comment 6•5 years ago
|
||
Added auxclick support. Calling preventDefault() on auxclick does not prevent back/forward navigation in Chrome.
Comment 7•5 years ago
|
||
I confirmed that both Microsoft's Mouse-KeyboardCenter and Logitech Options work equally. They sent x button messages first, then, WM_APPCOMMAND is sent. And on Chrome, only mouseup can prevent the default.
Comment 8•2 years ago
|
||
Any technical difficulties adding this feature?
The MDN browser compatibility table of MouseEvent.button and MouseEvent.buttons says Firefox has full support, but it's not true, because Firefox doesn't dispatch mousedown/pointerdown events for back/forward buttons, it's time to fix it or we should add an implementation note to that compatibility table.
Currently Alt + MouseWheel behaves as back/forward in Firefox, that behavior may easily cause unwanted page navigation but fortunately can be prevented by canceling keyup event of Alt key, while I cannot prevent back/forward behaviors triggered by mouse x-buttons.
Description
•