Losing mouse events on touchscreen devices

When I run the sketch below and press and release my actual mouse, I get mousePressed(), then tons of 'true’s until I let go, then mouseReleased(). Great!

But if I do the same thing on the touchscreen, I don’t get mousePressed() until after I release on the screen, and then I get both events, back to back (but never get mousePressed==true). Even while I’m holding the mouse down on the screen, the variable mousePressed never gets set to true.

Drags work as expected with the actual mouse, but on the screen I don’t get any events until I start to drag, and then I get mousePressed(), mousePressed==true, and mouseDragged() (but mosePressed==true only around mouseDragged events).

Is there another way to find out if the mouse has been pressed (and if it is still pressed), even if it’s the mouse/cursor on a touch screen?

public void draw() {
  if (mousePressed)
public void mousePressed() {
public void mouseDragged() {
public void mouseReleased() {

Hi @ottenm,

Are you running Processing Java on a touchscreen device? If so, can you specify the hardware model/OS?

Yes (Processing Java). Same results on two different laptops, both with actual mouse buttons and a touch screen. Both are Windows 10 Pro, one is a Lenovo p53s, the other is an HP Envy.

1 Like