Hello all.
I have a question about CP5 events.
Here’s small program:
import controlP5.*;
ControlP5 cp5;
boolean looping;
void setup() {
size(200, 200);
cp5 = new ControlP5(this);
cp5.addToggle("Click")
.setBroadcast(false)
.setValue(true)
.setColorLabel(0)
.setPosition(90, 90)
.setSize(20, 20)
.setBroadcast(true)
;
looping = true;
}
void draw() {
}
void Click(boolean theValue) {
println("looping = " + looping);
if (looping) {
looping = false;
noLoop();
} else {
looping = true;
loop();
}
}
The toggle button works fine. It changes state and colour properly. But when it's set to the off state a click anywhere on the sketch sets it back to the on state. I don't understand what's happening here.
Can anyone enlighten me?