controlp5 icon indicating copy to clipboard operation
controlp5 copied to clipboard

Issue with buttons on touch screen

Open sriranjanr opened this issue 5 years ago • 3 comments

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.

sriranjanr avatar Jan 01 '20 01:01 sriranjanr

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.

sriranjanr avatar Jan 01 '20 02:01 sriranjanr

Hi @sriranjanr, did you ever arrive at a solution to this problem (FYI @delaneyheileman)?

ryancoe avatar Aug 10 '20 20:08 ryancoe

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)); } } }

y-sembo avatar Aug 08 '23 02:08 y-sembo