# controlP5 button double tap problem

**URL:** https://discourse.processing.org/t/controlp5-button-double-tap-problem/10033
**Category:** Processing for Android
**Created:** [April 6, 2019, 4:07pm UTC](https://discourse.processing.org/t/controlp5-button-double-tap-problem/10033 "2019-04-06T16:07:49Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![jbnnx](https://avatars.discourse-cdn.com/v4/letter/j/ad7895/32.png) [@jbnnx](https://discourse.processing.org/u/jbnnx)
#### Post date: [April 6, 2019, 4:07pm UTC](https://discourse.processing.org/t/controlp5-button-double-tap-problem/10033/1 "2019-04-06T16:07:49Z")

</div>

hi

I’m using buttons to switch states and in Java it works fine but when I run my sketch on AndroidMode, I need to double tap to activate the button. Does anyone knows how to fix this?

here is my code:

final int stateMenu = 0;  
final int statePresetEditor = 1;  
final int stateLiveMode = 2;  
int state;  
ControlP5 cp5;

void setup() {  
size(400, 850);  
setupGUI();  
}

void draw() {  
background(0);  
switch(state) {  
case stateLiveMode:  
background(30);  
break;  
case statePresetEditor:  
background(255);  
break;  
case stateMenu:  
background(0);  
break;  
}  
}

//GUI

void setupGUI(){

cp5 = new ControlP5(this);

cp5.addButton(“Live”)  
.setValue(2)  
.setPosition(width/2, height/3)  
.setSize(150,30);

cp5.addButton(“Edit\_presets”)  
.setValue(1)  
.setPosition(width/2, height/3 + 90)  
.setSize(150,30);

cp5.addButton(“Menu”)  
.setValue(0)  
.setPosition(width/2, height\*2/3)  
.setSize(150,30);  
}

void Live(int value) {  
state = value;  
}

void Edit\_presets(int value) {  
state = value;  
}

void Menu(int value) {  
state = value;  
}  
`

---

<div class="post-metadata">

### Author: ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)
#### Post date: [April 8, 2019, 1:52am UTC](https://discourse.processing.org/t/controlp5-button-double-tap-problem/10033/2 "2019-04-08T01:52:01Z")

</div>

It seems this have been seen before [here](https://forum.processing.org/one/topic/controlp5-button-problem) Notice this is more than 1 year old. Dates are just not reported properly in archived forum material. I suggest to report the issue [here](https://github.com/sojamo/controlp5/issues) (I did not find any issue related to buttons so far).

You could try also using button widgets using the Android API. For instance, this is an older [post](https://forum.processing.org/two/discussion/14206/on-screen-buttons-without-apwidgets).

Kf
