We are about to switch to a new forum software. Until then we have removed the registration on this forum.
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.
Answers
If I understand correctly, you could solve your problem like this:
In other words, background(0); should be the first line of your code in draw().
Kf
That fixed the overwrite problem. To preserve the appearance at the suspended point I also had to add lines in the
if (runPause==false)
branch to display the frame count output and the last image generated for the 3D inner window.It now looks like this (although some of the functions aren't explained):
Thanks again "Kf". I expect not to bother the forum again unless problem is better thought out.
Glad everything is working. Good luck!
Kf