|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectcontrolP5.ControlEvent
public class ControlEvent
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.
/** * 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 |
---|
public static final int PRESSED
public static final int ENTER
public static final int LEAVE
public static final int RELEASED
public static final int RELEASEDOUTSIDE
public static int UNDEFINDED
public static int CONTROLLER
public static int TAB
public static int GROUP
Constructor Detail |
---|
public ControlEvent(Tab theController)
theController
- Controllerpublic ControlEvent(ControllerGroup theController)
theController
- ControllerMethod Detail |
---|
public float value()
public java.lang.String stringValue()
public float[] arrayValue()
public Controller controller()
public Tab tab()
public ControlGroup group()
public java.lang.String label()
public boolean isTab()
public boolean isController()
public boolean isGroup()
public java.lang.String name()
public int id()
public int type()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |