Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with buttons on touch screen #159

Open
sriranjanr opened this issue Jan 1, 2020 · 3 comments
Open

Issue with buttons on touch screen #159

sriranjanr opened this issue Jan 1, 2020 · 3 comments

Comments

@sriranjanr
Copy link

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
Copy link
Author

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.

@ryancoe
Copy link

ryancoe commented Aug 10, 2020

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

@y-sembo
Copy link

y-sembo commented Aug 8, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants