Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

ControlP5 Button from Class doesn't work when click on it

$
0
0

Hi! I'm creating a simple program with a class for creating all the controlP5 GUI, inside that class are buttons and other stuff but i'd like to manage the state of a button.

`

import controlP5.*;

class CAToolBox{

public ControlP5 cp5;

PFont font;

int caX; int caY; int caWidth; int caHeight;

boolean play = false; boolean generated = false;

CAToolBox(PApplet applet, PFont _font, int _x, int _y, int _caWidth, int _caHeight){ caX = _x; caY = _y; caWidth = _caWidth; caHeight = _caHeight; font = _font; cp5 = new ControlP5(applet);

this.drawCAToolBox(caX + 10, caY + 10);

}

void drawCAToolBox(int _x, int _y){

//Generate Button
cp5.addButton("Generate")
   .setPosition(_x +3 , _y + 65)
   .setSize(50, 22);

//Play & Pause Button
cp5.addButton("PlayPause")
   .setLabel("Pause")
   .setPosition(_x + 3 + 60 , _y + 65)
   .setSize(50, 22);

}

void PlayPause(){ play = !play;

checkLabelState();

}

void checkLabelState(){ if(play == false){ cp5.get(controlP5.Button.class, "PlayPause").setLabel("play"); }else{ cp5.get(controlP5.Button.class, "PlayPause").setLabel("pause"); } } }`

Any on how can i call the button in this class for working with my main window?


Viewing all articles
Browse latest Browse all 2896

Trending Articles