# Problem with android mousePressed

**URL:** <https://discourse.processing.org/t/problem-with-android-mousepressed/14933>\
**Category:** Processing for Android\
**Created:** [October 24, 2019, 8:26pm UTC](https://discourse.processing.org/t/problem-with-android-mousepressed/14933 "2019-10-24T20:26:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![anony](https://avatars.discourse-cdn.com/v4/letter/a/ce7236/32.png) [@anony](https://discourse.processing.org/u/anony)\
**Post date:** [October 24, 2019, 8:26pm UTC](https://discourse.processing.org/t/problem-with-android-mousepressed/14933/1 "2019-10-24T20:26:05Z")

</div>

First of all: sorry for my bad english, i’m not. I tried to use mousePressed in android, and initially works. But after some tests, i found a serius problem. By clicking quickly at the same time with two fingers and releasing them, the mousePressed function returned magically true, until i didn’t click again. I saw that this problem exists in every Android 9 Processing code. I’m very desperate, please help me!

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [October 24, 2019, 11:58pm UTC](https://discourse.processing.org/t/problem-with-android-mousepressed/14933/2 "2019-10-24T23:58:24Z")

</div>

I don’t have a phone with Android Pie, but has your phone a variable pointer speed ?  
Settings /General Management/Language and input/Pointer speed

---

<div class="post-metadata">

**Author:** ![Waboqueox](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/waboqueox/32/5643_2.png) [@Waboqueox](https://discourse.processing.org/u/Waboqueox)\
**Post date:** [October 25, 2019, 7:25am UTC](https://discourse.processing.org/t/problem-with-android-mousepressed/14933/3 "2019-10-25T07:25:43Z")

</div>

Hi @anony;

In order to understand better what is happening, maybe you can try to add this function and print info (from Android Studio):

```auto

import android.view.MotionEvent; 
.
.
.
    public void surfaceTouchEvent(MotionEvent event) {
        //call to keep mouseX, mouseY, etc updated
        super.surfaceTouchEvent(event);
        final int actionPeformed = event.getAction();
        println("Event: " + event + " Action: " + actionPeformed);
        }

```

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [October 25, 2019, 2:13pm UTC](https://discourse.processing.org/t/problem-with-android-mousepressed/14933/4 "2019-10-25T14:13:24Z")

</div>

Or you test the [Ketai library](https://github.com/ketai/ketai) which can capture [gestures.](https://github.com/ketai/ketai/blob/master/src/ketai/ui/KetaiGesture.java#L114).

---

<div class="post-metadata">

**Author:** ![Waboqueox](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/waboqueox/32/5643_2.png) [@Waboqueox](https://discourse.processing.org/u/Waboqueox)\
**Post date:** [October 25, 2019, 2:39pm UTC](https://discourse.processing.org/t/problem-with-android-mousepressed/14933/5 "2019-10-25T14:39:31Z")

</div>

yep, in fact my function is from some reference by ketai, but I realized I was not using it in that moment 😅

---

<div class="post-metadata">

**Author:** ![anony](https://avatars.discourse-cdn.com/v4/letter/a/ce7236/32.png) [@anony](https://discourse.processing.org/u/anony)\
**Post date:** [October 25, 2019, 7:37pm UTC](https://discourse.processing.org/t/problem-with-android-mousepressed/14933/6 "2019-10-25T19:37:01Z")

</div>

Hi @Waboqueox! I’m very happy, because of you. Your reference was very useful, and though the function return value is wrong (void), i found a very similar function that solve the problem!!  
To solve the double touch problem on android processing, we’ve to add on our sketch:

```auto
import android.view.MotionEvent;
...
...
...
public boolean surfaceTouchEvent(MotionEvent event) {
    if(event.getActionMasked() == MotionEvent.ACTION_UP){
        mousePressed=false;
    }
    return super.surfaceTouchEvent(event);
}

```

Finally, i can work on my future android projects. Thank you very much!
