Half of my problem is fixed with :
Code:
controlP5.setAutoInitialization(true);
but I still have a problem with the ScrollList and Groups.
I'm using a Scrolllist in order to access/show Groups. Everything works fine until I load a setup file.
When a setup file is loaded, the GUI is set to the loaded configuration, but I'm not anymore able to show/hide Groups using the ScrollList.
Here is an example of what I'm doing.
Code:
import controlP5.*;
ControlP5 controlP5;
ControlGroup groups[];
void setup() {
size(400,400);
frameRate(30);
controlP5 = new ControlP5(this);
controlP5.setAutoInitialization(true);
ScrollList l = controlP5.addScrollList("myList",10,10,120,280);
l.setLabel("something else");
for(int i=0;i<5;i++) {
controlP5.Button b = l.addItem("a"+i,i);
b.setId(100 + i);
}
groups = new ControlGroup[5];
for(int i=0;i<5;i++) {
groups[i] = controlP5.addGroup(i+"_gp",210,10+(50*i));
groups[i].hide();
groups[i].setMoveable(false);
}
}
void controlEvent(ControlEvent theEvent) {
println(theEvent.controller().id()+" / "+
theEvent.controller()+" / "+
theEvent.controller().value()
);
int controllerID = theEvent.controller().id();
if (controllerID > 99 && controllerID < 200 ) {
for(int i=0;i<5;i++) {
ControlGroup gp = (ControlGroup)groups[i];
gp.hide();
}
}
ControlGroup gp = (ControlGroup)groups[controllerID-100];
gp.show();
}
void draw() {
background(0);
}
void keyPressed() {
if(key=='s') {
controlP5.save("controlP5.xml");
} else if (key=='l') {
controlP5.load("controlP5.xml");
}
}
Use the ScrollList to display a specific group. Save the state by pressing 's'. Relaunch the applet or play with it, and then load the saved setup file. The saved stated will be activated. But it is not possbile to display other groups, even if the scroollist is firing events.
What am I missing ?
Thanks,