controlP5
Class ControlEvent

java.lang.Object
  extended by controlP5.ControlEvent

public class ControlEvent
extends java.lang.Object

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
/**
 * ControlP5 ControlEvent
 * by andreas schlegel, 2009
 */
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;  
  }
}

Field Summary
static int CONTROLLER
           
static int ENTER
           
static int GROUP
           
static int LEAVE
           
static int PRESSED
           
static int RELEASED
           
static int RELEASEDOUTSIDE
           
static int TAB
           
static int UNDEFINDED
           
 
Constructor Summary
ControlEvent(ControllerGroup theController)
           
ControlEvent(Tab theController)
           
 
Method Summary
 float[] arrayValue()
          returns a float array, apllies for e.g.
 Controller controller()
          returns the instance of the controller.
 ControlGroup group()
          return the tab that evoked the event.
 int id()
           
 boolean isController()
          check if the event was evoked by a controller.
 boolean isGroup()
          check if the event was evoked by a controlGroup.
 boolean isTab()
          check if the event was evoked by a tab.
 java.lang.String label()
          get the label of the controller that evoked the event.
 java.lang.String name()
           
 java.lang.String stringValue()
          returns a string value if applicable to the controller e.g.
 Tab tab()
          return the tab that evoked the event.
 int type()
           
 float value()
          returns the value of the controller as float.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PRESSED

public static final int PRESSED
See Also:
Constant Field Values

ENTER

public static final int ENTER
See Also:
Constant Field Values

LEAVE

public static final int LEAVE
See Also:
Constant Field Values

RELEASED

public static final int RELEASED
See Also:
Constant Field Values

RELEASEDOUTSIDE

public static final int RELEASEDOUTSIDE
See Also:
Constant Field Values

UNDEFINDED

public static int UNDEFINDED

CONTROLLER

public static int CONTROLLER

TAB

public static int TAB

GROUP

public static int GROUP
Constructor Detail

ControlEvent

public ControlEvent(Tab theController)
Parameters:
theController - Controller

ControlEvent

public ControlEvent(ControllerGroup theController)
Parameters:
theController - Controller
Method Detail

value

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

Returns:
float

stringValue

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

Returns:
String

arrayValue

public float[] arrayValue()
returns a float array, apllies for e.g. Range.

Returns:

controller

public Controller controller()
returns the instance of the controller.

Returns:
Controller Bang Button Knob Numberbox Radio Slider Textfield Toggle MultiList Matrix

tab

public Tab tab()
return the tab that evoked the event.

Returns:
Tab Tab

group

public ControlGroup group()
return the tab that evoked the event.

Returns:
Tab Tab

label

public java.lang.String label()
get the label of the controller that evoked the event.

Returns:
String

isTab

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

Returns:
boolean

isController

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

Returns:
boolean

isGroup

public boolean isGroup()
check if the event was evoked by a controlGroup.

Returns:
boolean

name

public java.lang.String name()

id

public int id()

type

public int type()


processing library controlP5 by Andreas Schlegel. (c) 2010