CreateJS / EaselJS

The Easel Javascript library provides a full, hierarchical display list, a core interaction model, and helper classes to make working with the HTML5 Canvas element much easier.
http://createjs.com/
MIT License
8.12k stars 1.97k forks source link

click event fired for both left and right mouse button #926

Open martinAnsty opened 6 years ago

martinAnsty commented 6 years ago

At the very least this is a mismatch between actual behaviour and documented behaviour. The docs say click events are dispatched when the left mouse button is pressed and released on a display object: https://github.com/CreateJS/EaselJS/blob/aea6424e62ad366807be2936ecdde9d4ebac352e/src/easeljs/display/DisplayObject.js#L546-L551

This matches the behaviour of native dom events, where click is fired for the primary mouse button but not the secondary button (unlike mousedown/up which fire for any mouse button).

However EaselJS doesn't listen to native click events on the canvas element, instead it dispatches its click events from the mouseup listener. The only check is that the mouseup occured over the same display object as the originating mousedown: https://github.com/CreateJS/EaselJS/blob/aea6424e62ad366807be2936ecdde9d4ebac352e/src/easeljs/display/Stage.js#L711

Should EaselJS be checking the mouse button before dispatching the click event? (That's what PixiJS does)

Or are the docs wrong, and click events are supposed to be dispatched for the secondary mouse button?

shindeshubham582 commented 2 years ago

Click should work on a primary key but it is also working for other keys also. I have came across one scenario where pressUp of left click is getting missed and that is creating an issue. steps are as follows: 1.left mouseDown on object. 2.right mouseDown on same object. 3.right pressUp on object.

if we follow this order left mouseUp is getting missed it is not getting fired nor it is present after that point.