I am trying to change the label on a toggle control from the controlP5 library. The toggle is initialized to "true" with a caption label text of "Running". (Of course, cp5 displays all-caps RUNNING.) When the toggle (identified as "RunPauseToggle") is clicked on, the draw() loop is suspended (Pause mode) until the next toggle. The code fragments -- thanks to kfrajer -- make the run/pass action work. But I can't make the PAUSE text appear alone, it overwrites the preceding RUNNING label.
Here are the important bits. First, near the top is:
boolean runPause = true;
In the setup() block, among other lines, is this:
RunPauseToggle = cp5.addToggle("runPause")
.setPosition(ctrlOffsetX, ctrlOffsetY)
.setSize(100, ctrlSizeY)
.setFont(font)
.setCaptionLabel("Running")
.setColorCaptionLabel(0)
.setValue(true)
.setMode(ControlP5.SWITCH)
;
At the beginning of the draw() loop is this:
void draw() {
if(runPause == false){
RunPauseToggle.setCaptionLabel("Paused");
return;
} else {
RunPauseToggle.setCaptionLabel("Running");
}
As above, the first toggle of RunPauseToggle suspends draw() but writes PAUSED over RUNNING. The 2nd toggle displays a clean copy of RUNNING. This behavior continues on successive toggles. I've tried setting the label to all blanks (" ") and to no text ("") ahead of the "Paused" command line but that doesn't work. I've browsed the heck out of the forum but without finding a working example of what I want to do.
Thanks for looking and (fingers crossed) responding.