I'm relatively new to eclipse and I'm having trouble figuring out the scopes of ControlP5.
I have a boolean called isGuideVisible that i'm trying to link up with ControlP5. MySketch is calling the boolean but the value is not changing when I click on the button. Am I missing something?
- import processing.core.PApplet;
- public class MySketch extends PApplet {
- MyControls controls;
- public void setup() {
- controls = new MyControls(this);
- controls.createControls();
- }
- public void draw() {
- // always printing false, doesn't toggle although visually it does.
- System.out.print(controls.isGuideVisible);
- }
- }
- import controlP5.ControlEvent;
- import controlP5.ControlP5;
- import processing.core.PApplet;
- public class MyControls {
- PApplet parent;
- ControlP5 controlP5;
- public boolean isGuideVisible=false;
- MyControls(PApplet p) {
- parent = p;
- }
- public void createControls() {
- controlP5 = new ControlP5(parent);
- controlP5.addToggle("toggleIsGuideVisible", isGuideVisible, 10 , 10, 100, 100);
- }
- public void toggleIsGuideVisible(boolean theFlag) {
- isGuideVisible = theFlag;
- }
- }
1