touchEnded() clicks twice


#1

Hi everyone,
I am having some problem with touchEnded() function.
I am using it to switch from a case to another and it works fine with the mouse on laptop.
However, if I use a tablet it seems that the touch lasts longer as there was a lag between the touch and the end of the touch. Or it’s like the touch happened twice.

For example if I click in (xpos, ypos) and I am in case1, when it switches on case2 the touch is still active in the same position and it messes up with the things happening in the second case.

I am trying to understand what could be wrong but I can’t. The mouse click works well, the touch doesn’t.

here is a short version of the code. I have already tried to avoid the first conditional (mouseButton===LEFT) but the problems is still there.

Any idea anyone on what may be going on?

Thanks!

if(mouseButton === LEFT){
		switch(pages){

			case 'one':

				//code here
				pages = 'two';

			break;

			case 'two':
				//code here
				pages = 'three';

			break;
}
}

#2

Check these next links as they can provide some suggestions that could help in your current isssue:

https://forum.processing.org/two/discussion/19344/mouse-and-touch-events-fire-twice

https://github.com/processing/p5.js/issues/1815

https://forum.processing.org/two/discussion/20372/touchended-fires-evt-is-undefined

Where are you calling this function from? It is better to provide a minimum version of your code demonstrating your problem.

Kf


#3

Hi, thanks for replying. I’ve read your links and I started exploring from there.
Apparently the problem is in the browser that I use.
Chrome should read both mouse and touch and give priority to whatever device is used but Firefox or other browsers don’t. However, I couldn’t find a way to fix it even following the examples provided.
At the moment I am thinking to avoid touch devices because I don’t have much time but I would like to get back to it later.

I will post some code that makes sense as soon as I can :slight_smile:

Cheers