apollo
YaBB Newbies
Offline
Posts: 8
controlP5 - scrollList controll event handling
Apr 5th , 2009, 5:51am
Hej, i have a problem handling the control events/values of a scrollList correctly. I want to use scrollList with a fixed id an allocate the selected values to a public variable (as it works for a single buttom event). As i do it i get: "ERROR. an error occured while forwarding a Controller value to a method in your program. please check your code for any possible errors that might occur in this method . e.g. check for casting errors, possible nullpointers, array overflows ... . method: controlEvent exception: java.lang.reflect.InvocationTargetException"example code: import controlP5.*; ControlP5 controlP5; public int a; //controller value from button public int b; //controller value from list void setup() { size(400,400); frameRate(30); controlP5 = new ControlP5(this); controlP5.addNumberbox("myButton",a,100,160,100,14).setId(1); ScrollList l = controlP5.addScrollList("myList",100,100,120,280); l.setLabel("List"); for(int i=0;i<4;i++) { controlP5.Button b = l.addItem("a"+i,i); b.setId(2); // fixed id 2 for scroll list } } void draw() { background(0); //println("controller value from button " + a); //println("controller value from list " + b); } void controlEvent(ControlEvent theEvent) { switch(theEvent.controller().id()) { case(1): /*events from my button*/ a = (int)(theEvent.controller().value()); break; case(2): /* events from myList */ b = (int)(theEvent.controller().value()); break; } } void myList(int theValue) { println("123"); }