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 for touchEnded triggers twice among other issues with touchEnded/mouseReleased on mobile #6738

Merged
merged 3 commits into from
Jan 23, 2024

Conversation

RandomGamingDev
Copy link
Contributor

@RandomGamingDev RandomGamingDev commented Jan 14, 2024

Resolves #6737

Changes:

Adds an instance variable called touchend to p5 and changed p5.prototype._ontouchend & p5.prototype._onmouseup to function as documented.

On touchscreen

  • mouseReleased and touchEnded no longer both trigger if they're both present (same for mouseReleased)
  • If either is without the other it doesn't triggers twice anymore

PR Checklist

@@ -731,6 +731,11 @@ p5.prototype._onmouseup = function(e) {
const context = this._isGlobal ? window : this;
let executeDefault;
this._setProperty('mouseIsPressed', false);

if (this.touchend) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this get called implicitly because the browser triggers a mouse event after the touch event? It'd be helpful adding a comment here explaining if so.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add a comment for this and the other PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added the comment

@davepagurek
Copy link
Contributor

I think this looks good to me, but could an events steward with more familiarity with the control flow double check? @limzykenneth, @richardegil, @angelabelle, @littlejacinthe, @TanviKumar, @tuminzee

@RandomGamingDev
Copy link
Contributor Author

RandomGamingDev commented Jan 14, 2024

I think this looks good to me, but could an events steward with more familiarity with the control flow double check? @limzykenneth, @richardegil, @angelabelle, @littlejacinthe, @TanviKumar, @tuminzee

Could you guys also check if this sorta thing happens to any of the other events for touchscreens? The fact that this happened twice (#6740) might mean that this sorta issue's in other event handlers that deal with touch as well.

@Garima3110
Copy link
Member

Hello everyone, I just want to add that I did the tests for this on Safari, and it all looks good. I also tried it out on Chrome on my Android phone, and Safari on my iPhone behaved the same way. So, it seems like things are working fine on both browsers.

Copy link
Contributor

@davepagurek davepagurek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for testing this out! I'm going to merge this in now that we've confirmed it also works as expected in different platforms.

@davepagurek davepagurek merged commit 9ef898f into processing:main Jan 23, 2024
2 checks passed
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.

touchEnded triggers twice among other issues with touchEnded/mouseReleased on mobile
3 participants