ControlP5 buttons/controls trigger automatically on sketch start...

edited November 2013 in Library Questions

Hello all

Can't seem to work this out. When I make a ControlP5 control and start my sketch, it automatically triggers as if it was clicked.

Anyone know about this/how to stop it?

Cheers

Answers

  • edited November 2013 Answer ✓

    hi, I hope the following example is self explanatory.

    import controlP5.*;
    
    void setup() {
      ControlP5 cp5 = new ControlP5(this);
      // the following controller initialization will not call test() since broadcast is temporarily disabled
      cp5.addSlider("test").setBroadcast(false).setValue(50).setRange(0,200).setBroadcast(true);
    
      // the following line will call event() twice, once for setValue and once for setRange  
      cp5.addSlider("event").setValue(50).setRange(0,200);
    
      // to prevent a controller from triggering an event, use setBroadcast(false)
    
    }
    
    void draw() {
    
    }
    
    void test(float f) {
      println("test test.");
    }
    
    void event(float f) {
      println("event event.");
    }
    
  • Perfect! Thanks!

Sign In or Register to comment.