# Losing mouse events on touchscreen devices

**URL:** https://discourse.processing.org/t/losing-mouse-events-on-touchscreen-devices/39613
**Category:** Coding Questions
**Created:** [November 7, 2022, 11:54am UTC](https://discourse.processing.org/t/losing-mouse-events-on-touchscreen-devices/39613 "2022-11-07T11:54:01Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![ottenm](https://avatars.discourse-cdn.com/v4/letter/o/f08c70/32.png) [@ottenm](https://discourse.processing.org/u/ottenm)
#### Post date: [November 7, 2022, 11:54am UTC](https://discourse.processing.org/t/losing-mouse-events-on-touchscreen-devices/39613/1 "2022-11-07T11:54:01Z")

</div>

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?

```auto
public void draw() {
  if (mousePressed)
    System.out.println("true");
}
public void mousePressed() {
  System.out.println("mousePressed()");
}
public void mouseDragged() {
  System.out.println("mouseDragged()");
}
public void mouseReleased() {
  System.out.println("mouseReleased()");
}

```

---

<div class="post-metadata">

### Author: ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)
#### Post date: [November 7, 2022, 1:07pm UTC](https://discourse.processing.org/t/losing-mouse-events-on-touchscreen-devices/39613/2 "2022-11-07T13:07:06Z")

</div>

Hi @ottenm,

> [@ottenm](#):
>
> But if I do the same thing on the touchscreen

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

---

<div class="post-metadata">

### Author: ![ottenm](https://avatars.discourse-cdn.com/v4/letter/o/f08c70/32.png) [@ottenm](https://discourse.processing.org/u/ottenm)
#### Post date: [November 7, 2022, 3:47pm UTC](https://discourse.processing.org/t/losing-mouse-events-on-touchscreen-devices/39613/3 "2022-11-07T15:47:58Z")

</div>

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.
