# ControlEvent

description
  a controlEvent is sent to a PApplet whenever a controlP5 action has been made. you can receive events from controllers and tabs. by default tab events are disabled and have to be enabled with Tab.activateEvent(). for detailed information see the tab documentation.

+Example

      import controlP5.*;

      ControlP5 controlP5;

      public int myColorRect = 200;

      public int myColorBackground = 100;

      void setup() {
        size(400,400);
        frameRate(25);
        controlP5 = new ControlP5(this);
        controlP5.addNumberbox("n1",myColorRect,100,160,100,14).setId(1);
        controlP5.addNumberbox("n2",myColorBackground,100,200,100,14).setId(2);
        controlP5.addTextfield("n3",100,240,100,20).setId(3);
      }

      void draw() {
        background(myColorBackground);
        fill(myColorRect);
        rect(0,0,width,100);
      }

      void controlEvent(ControlEvent theEvent) {
        println("got a control event from controller with id "+theEvent.controller().id());
        switch(theEvent.controller().id()) {
          case(1):
          myColorRect = (int)(theEvent.controller().value());
          break;
          case(2):
          myColorBackground = (int)(theEvent.controller().value());
          break;
          case(3):
          println(theEvent.controller().stringValue());
          break;
        }
      }

Methods

controller ( )
  returns the instance of the controller.

isController ( )
  check if the event was evoked by a controller.

isTab ( )
  check if the event was evoked by a tab.

label ( )
  get the label of the controller that evoked the event.

stringValue ( )
  returns a string value if applicable to the controller e.g. textfield has a string value.

tab ( )
  return the tab that evoked the event.

value ( )
  returns the value of the controller as float.

usage
  Web & Application

related
  - ControlP5
  - Tab