Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

pointer cancel event with mouse buttons #166

Closed
Steditor opened this issue Mar 4, 2015 · 7 comments
Closed

pointer cancel event with mouse buttons #166

Steditor opened this issue Mar 4, 2015 · 7 comments

Comments

@Steditor
Copy link
Contributor

Steditor commented Mar 4, 2015

Maybe again my misunderstanding of the recommendation, but:

What I do:
I press one mouse button (and keep it pressed down), then press a second mouse button.

What I expect:
A pointerdown event is triggered with the first mouse button.

A user agent MUST fire a pointer event named pointerdown when a pointer enters the active buttons state. For mouse, this is when the device transitions from no buttons depressed to at least one button depressed.

To detect the second mouse button I can inspect changes to the button/buttons properties.

chorded button presses can be detected by inspecting changes to the button and buttons properties

What I get
A pointerdown event is trigerred with the first mouse button.
(So far no problems)
The second mouse button results in a pointercancel event and a new pointerdown event
which puzzles me. In my understanding I will only receive pointer events...

when a pointer enters the active buttons state. For mouse, this is when the device transitions from no buttons depressed to at least one button depressed.

But the mouse already had a pressed button. (In contrast to "no buttons depressed")

One might argue, that the pointercancel event causes the mouse to leave the active buttons state and therefore a pointerdown event is correct. I just would not expect a pointercancel event in the first place, because I can't find any of the conditions met:

The user agent has determined that a pointer is unlikely to continue to produce events (for example, because of a hardware event).
After having fired the pointerdown event, if the pointer is subsequently used to manipulate the page viewport (e.g. panning or zooming).

But the section is non-normative, so the polyfill can just decide, that a pointercancel event has to be fired. In this case I'd expect some more events:

After firing the pointercancel event, a user agent MUST also fire a pointer event named pointerout followed by firing a pointer event named pointerleave.

But I don't receive any of those, but only the new pointerdown event.

Any hints on this issue?

@scottgonzalez
Copy link
Contributor

Performing multiple button presses with a mouse is an interesting case because the action that you started may be canceled, depending on the order in which you release the buttons. For example, primary down, secondary down, secondary up, primary up will result in a click because the primary button was the first and last action. But primary down, secondary down, primary up, secondary up won't result in a click. Similarly secondary down, primary down, secondary up, primary up won't result in a click. In any case, the context menu would open on secondary down and close on the first up, regardless of which button is released. It's also impossible to detect when multiple mice are being used vs. a single mouse.

However, I do agree that it seems odd for a pointercancel event in this case.

@Steditor
Copy link
Contributor Author

Steditor commented Mar 4, 2015

It gets a little easier if you preventDefault the contextmenu or use e.g. the mouse wheel instead of the secondary button - the result is the same but without a context menu "messing up" the events.

@Steditor
Copy link
Contributor Author

Steditor commented Mar 5, 2015

On my fork (Lowfab/PEP) I have made some changes to better match the behavior of the native implementation of IE regarding button states and also firing of pointerdown/up-events.

The fork is probably not useful for a pull request, because I have also added the "binary" to be able to directly require the github repo as npm dependency, but feel free to copy my changes if you find them useful.

@scottgonzalez
Copy link
Contributor

We couldn't do that without a CLA. A PR would really help if you want your changes to be reviewed. I don't really think the team wants to dig through commits in your master branch.

@Steditor
Copy link
Contributor Author

Steditor commented Mar 5, 2015

Done and done, see #168

@scottgonzalez
Copy link
Contributor

Thanks!

scottgonzalez pushed a commit that referenced this issue Oct 1, 2015
@patrickhlauke
Copy link
Collaborator

PEP has now entered emeritus status at the OpenJS Foundation. This repository is now archived.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants