I am using the ControlP5 GUI library.
I want to change the text displayed in TextLabel when triggered by some other event. For example in the following case when I press the button.
So I tried two methods marked by OPTION 1 and OPTION 2 in the following code.
Option 2 is working but Option 1 is not working.
I don’t want to declare a label variable. so how can I make Option 1 work?
Please Help.
import controlP5.*;
ControlP5 cp5;
Textlabel myTextlabelA;
void setup() {
size(700,400);
cp5 = new ControlP5(this);
myTextlabelA = cp5.addTextlabel("label")
.setText("A single ControlP5 textlabel, in yellow.")
.setPosition(100,50)
.setColorValue(0xffffff00)
.setFont(createFont("Georgia",20))
;
cp5.addToggle("AAA").setPosition(200,200).align(CENTER,CENTER,CENTER,CENTER);
}
void draw() {
background(0);
}
void AAA(int x){
cp5.getController("label").setText("Value="+x); /// OPTION 1
//myTextlabelA.setText("Value="+x); /// OPTION 2
}