hi, controlP5 controllers come in 2 types, Controller and ControllerGroup. ControllerGroups were added after introducing more complex controller-types - such as ListBox, DropdownList or RadioButton - as compared to simpler Controllers including Button, Slider or Toggle. The plugTo method is only implemented for the Controller class but not for ControllerGroup, therefore the plugTo method cannot be found for the DropdownList.
I wouldn't call this a bug, but a missing feature.
An alternative method to receive events from a ControllerGroup / Dropdownlist:
- import controlP5.*;
- ControlP5 cp5;
- DropdownList d1, d2;
- void setup() {
- size(400, 400);
- cp5 = new ControlP5(this);
- d1 = cp5.addDropdownList("myList-d1", 90, 100, 100, 120);
- for (int i=0;i<40;i++) { d1.addItem("item "+i, i); }
- d2 = cp5.addDropdownList("myList-d2", 210, 100, 100, 120);
- for (int i=0;i<40;i++) { d2.addItem("item "+i, i); }
- }
- void controlEvent(ControlEvent theEvent) {
- if (theEvent.isGroup()) {
- // checks if the Event was triggered from a ControllerGroup
- println(theEvent.getGroup().getValue()+" from "+theEvent.getGroup());
- if(theEvent.getGroup().equals(d1)) {
- println("d1");
- } else if(theEvent.getGroup().equals(d2)) {
- println("d2");
- }
- }
- }
- void draw() {
- background(128);
- }
if you are using a version >=
0.6.5
- import controlP5.*;
- ControlP5 cp5;
- DropdownList d1, d2;
- void setup() {
- size(400, 400);
- cp5 = new ControlP5(this);
- d1 = cp5.addDropdownList("myList-d1", 90, 100, 100, 120);
- for (int i=0;i<40;i++) { d1.addItem("item "+i, i); }
- d2 = cp5.addDropdownList("myList-d2", 210, 100, 100, 120);
- for (int i=0;i<40;i++) { d2.addItem("item "+i, i); }
- }
- void controlEvent(ControlEvent theEvent) {
- if(theEvent.isFrom(d1)) {
- println("Got something from dropdownlist d1.");
- } else if (theEvent.isFrom(d2)) {
- println("Got something from dropdownlist d2.");
- }
- }
- void draw() {
- background(128);
- }