Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mouseup/mousedown event handler, not working properly with different mouse buttons #555

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

noobiept
Copy link
Contributor

Fixing this issue: #551

By setting the id with the mouse button, it will end up with a separate object for each button. Before the same object would be reused regardless of what mouse button was pressed.

Test I used:

// ...
circle.addEventListener('pressup', function(event)
    {
    console.log(event.type, event.nativeEvent.which);
    });
circle.addEventListener('mousedown', function(event)
    {
    console.log(event.type, event.nativeEvent.which);
    });
stage.addEventListener('stagemouseup', function(event)
    {
    console.log(event.type, event.nativeEvent.which);
    });
// ...

Press the mouse button and the middle mouse button at same time, then release them.
Before this patch you get:

mousedown 1
mousedown 2
stagemouseup 2
pressup 2

After:

mousedown 1
mousedown 2
stagemouseup 2
pressup 2
stagemouseup 1
pressup 1

@noobiept
Copy link
Contributor Author

New test:

circle.addEventListener('pressup', function(event)
    {
    console.log(event.type, event.nativeEvent.which, event.pointerID);
    });
// etc

Result after patch:

mousedown 1 -1
mousedown 2 -2
stagemouseup 2 -2
pressup 2 -2
pressmove 1 -1
stagemouseup 1 -1
pressup 1 -1

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

Successfully merging this pull request may close these issues.

1 participant