You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
mouseButton on touch device gives 0 for first click (and for any long presses before the first click). only presses after that first click give 'left'.
Steps:
run on a touch device
note that the first click shows mouseButton value to be 0
note that only on second click it changes to 'left'
rerun and now do long presses instead of clicks. note that the value is 0 until you do the second click
As we can see from code, touchStarted doesn't set mouseButton, adding a line should solve this issue. @davepagurek thoughts on this? @eyaler, Meanwhile mousePressed function can be used as a workaround.
p5.prototype._ontouchstart=function(e){constcontext=this._isGlobal ? window : this;letexecuteDefault;this._setProperty('mouseIsPressed',true);this._updateTouchCoords(e);this._updateNextMouseCoords(e);this._updateMouseCoords();// reset pmouseXY at the start of each touch eventif(typeofcontext.touchStarted==='function'){executeDefault=context.touchStarted(e);if(executeDefault===false){e.preventDefault();}
@wayneharish10 thanks! Due to #7195 I cannot use mousePressed(). IIUC, it would only be called on release for short click and not at all for long press. I am actually calling mousePressed() my self from touchStart() to overcome that, and allow a unified interface.
This looks like something that might get resolved in p5 2.0 due to this change #7378 which handles both mouse and touch events using the browser's pointer API rather than trying to handle both separately.
Most appropriate sub-area of p5.js?
p5.js version
1.11.1
Web browser and version
firefox 133 android, chrome 131 android
Operating system
android
Steps to reproduce this
mouseButton on touch device gives 0 for first click (and for any long presses before the first click). only presses after that first click give 'left'.
Steps:
Snippet:
or run this
The text was updated successfully, but these errors were encountered: