動作環境
Processing 3.1.1 on Windows 8.1 pro(64bit)
Library: ControlP5 v2.2.6
以下のListBoxの実装を試したが、Event1, Event2ともに発生しない。
import controlP5.*;
ControlP5 controlP5;
int myCurrentIndex = 0;
String[] tokens;
void setup() {
size(500,500);
frameRate(10);
controlP5 = new ControlP5(this);
ListBox lst = controlP5.addListBox("myList", 20, 40, 80, 200);
tokens = new String[10];
tokens[0] = "Hello";
tokens[1] = "Hi";
tokens[2] = "Ca va bien?";
lst.addItem(tokens[0], 0);
lst.addItem(tokens[1], 1);
lst.addItem(tokens[2], 2);
}
void controlEvent(ControlEvent theEvent) {
if (theEvent.isGroup()) {
println("Event1");
println(theEvent.getGroup().getValue() + " from " + theEvent.getGroup());
}
if (theEvent.isGroup() && theEvent.getName().equals("myList")) {
println("Event2");
myCurrentIndex = (int)theEvent.getGroup().getValue();
}
}
void draw() {
background(0);
fill(255);
if (myCurrentIndex >= 0) {
text(tokens[myCurrentIndex], 200, 40);
}
}
I guess ListBox is also depreciated and they recommend you use scrollableList instead.
リンク先のリンク先のjavadocを見てもListBox がdepreciated というのは見つかってはいないが、scrollableList で代用できるのであればそれでいい。