-
-
Couldn't load subscription status.
- Fork 3.6k
Description
Most appropriate sub-area of p5.js?
- Accessibility
- Color
- Core/Environment/Rendering
- Data
- DOM
- Events
- Image
- IO
- Math
- Typography
- Utilities
- WebGL
- Build process
- Unit testing
- Internationalization
- Friendly errors
- Other (specify if possible)
p5.js version
1.9.1
Web browser and version
Chrome
Operating system
Windows
Steps to reproduce this
Steps:
- Describe the interaction using only mousePressed and mouseReleased.
- Inside the draw loop, use mouseIsPressed to perform console output.
- In the case of touch, mousePressed and mouseReleased are executed in this order at the timing of release.
Snippet:
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
if(mouseIsPressed){
console.log("is");
}
}
function mousePressed(){
console.log("mousePressed");
}
function mouseReleased(){
console.log("mouseReleased");
}2024-09-10.23-30-17.mp4
Note that I use a stylus pen for touch because to check on a desktop, but the results are the same on a mobile phone.
In the above code, in the case of touch, only the processing at mouseIsPressed is executed, and at the timing of release, the contents of mousePressed and mouseReleased are executed in this order.
However, the following code achieves the intended behavior even on touch operations. In other words, first mousePressed is executed, then the process for mouseIsPressed is executed in the draw loop, and finally mouseReleased is executed.
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
if(mouseIsPressed){
console.log("is");
}
}
function touchStarted(){
console.log("mousePressed");
}
function touchEnded(){
console.log("mouseReleased");
}Regarding the mouse, either code results in the intended behavior.
In other words, if you only describe the interaction when using the mouse, mousePressed() will not be executed when touch is started.
Furthermore, in the case of the first code above, if the start and end positions of the touch are different, neither mousePressed nor mouseReleased seems to be executed.
2024-09-10.23-56-55.mp4
It's hard to see in the video, but if you touch it, move it, and then release it, none of the processes will be executed. Any second code will be executed.
OpenProcessing: Interaction bug