controlp5
controlp5 copied to clipboard
Issue with buttons on touch screen
There is a problem with buttons on touch screen. I need to double press the button to make it work. I followed the guidelines in #34 and recompiled the library but now when I press a button it remains in the pressed state and deactivates all the UI as the button pressed does not get released.
I think the events are not getting updated after the press action. And since the following code is creating error. if ( cp5.blockDraw == false ) { if ( cp5.isAndroid ) { mouseEvent( cp5.papplet.mouseX , cp5.papplet.mouseY , cp5.papplet.mousePressed ); } else { } else if ( !cp5.isTouch ) { updateEvents( ); }
This might be the problem.
Hi @sriranjanr, did you ever arrive at a solution to this problem (FYI @delaneyheileman)?
import controlP5.*;
ControlP5 cp5; Button button; color bgColor;
void setup() { size(400, 400); noCursor(); cp5 = new ControlP5(this);
button = cp5.addButton("button") .setPosition(100, 100) .setSize(100, 50) .setLabel("Press Me");
bgColor = color(255); }
void draw() { background(bgColor); }
void mousePressed() { ControllerInterface<?> c = cp5.getController("button"); if (c instanceof Button) { Button b = (Button) c; if (mouseX > b.getPosition()[0] && mouseX < b.getPosition()[0] + b.getWidth() && mouseY > b.getPosition()[1] && mouseY < b.getPosition()[1] + b.getHeight()) { bgColor = color(random(255), random(255), random(255)); } } }