Skip to content

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

Open
noobiept wants to merge 2 commits into
CreateJS:masterfrom
noobiept:fix_mouse_event
Open

Fix mouseup/mousedown event handler, not working properly with different mouse buttons#555
noobiept wants to merge 2 commits into
CreateJS:masterfrom
noobiept:fix_mouse_event

Conversation

@noobiept

Copy link
Copy Markdown
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
Copy Markdown
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
varyndev added a commit to VarynInc/EaselJS that referenced this pull request Dec 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant