-
Notifications
You must be signed in to change notification settings - Fork 0
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
Changed mouse button to object #1
base: dev-2.0
Are you sure you want to change the base?
Conversation
src/events/pointer.js
Outdated
@@ -1479,6 +1485,8 @@ function pointer(p5, fn){ | |||
|
|||
if(e.pointerType == 'touch'){ | |||
this._activeTouches.delete(e.pointerId); | |||
} else { | |||
this._setMouseButton(e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like if you have two fingers down, and then raise one, this would cause mouseButton.left
to become false because the pointer that was lifted would now have no left button. It might be prefereable to, when this happens, keep mouseButton.left
true if any remaining touch still has a left button down.
So maybe that would mean adding a buttons
property on each active touch, and when an event happens, we loop through activeTouches
and set left = activeTouches.some(touch => touch.buttons.left)
? (I think this would also mean using activeTouches
for all pointer types, not just touch, to still handle the single-pointer desktop case correctly.
Does that behaviour sound like what we want?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it makes more sense for mouseButton.left
to remain true as long as any touch action is present on the screen. Setting it to false in onpointerup
, using something like this, might work well:
if (this._activeTouches.size === 0) {
Object.keys(this.mouseButton).forEach((key) => (this.mouseButton[key] = false));
}
This approach means we treat all active touches on the screen as left touches, correct? In that case, right and center clicks would only be supported by a mouse if I'm not wrong.
71a35d6
to
dc45d60
Compare
0d19067
to
6f70ec1
Compare
6f70ec1
to
79d66c1
Compare
Resolves processing#6847
Changes:
mouseButton
from a string to object.mouseButton
now intends to track the current state of mouse buttons, showing which buttons are pressed at any given moment.This work is done over the PR processing#7378
PR Checklist
npm run lint
passes