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

Changed mouse button to object #1

Open
wants to merge 4 commits into
base: dev-2.0
Choose a base branch
from
Open

Changed mouse button to object #1

wants to merge 4 commits into from

Conversation

diyaayay
Copy link
Owner

@diyaayay diyaayay commented Dec 1, 2024

Resolves processing#6847

Changes:

  • Changed 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

@@ -1479,6 +1485,8 @@ function pointer(p5, fn){

if(e.pointerType == 'touch'){
this._activeTouches.delete(e.pointerId);
} else {
this._setMouseButton(e);

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?

Copy link
Owner Author

@diyaayay diyaayay Dec 2, 2024

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.

@diyaayay diyaayay changed the base branch from Event-ordering to dev-2.0 December 3, 2024 17:14
@diyaayay diyaayay changed the base branch from dev-2.0 to Event-ordering December 3, 2024 17:17
@diyaayay diyaayay changed the base branch from Event-ordering to dev-2.0 December 3, 2024 17:17
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.

2 participants