Using this MWE from the documentation:
import controlP5.*;
import java.util.*;
ControlP5 cp5;
void setup() {
size(400, 400);
cp5 = new ControlP5(this);
List l = Arrays.asList("a", "b", "c", "d", "e", "f", "g", "h");
/* add a ScrollableList, by default it behaves like a DropdownList */
cp5.addScrollableList("dropdown")
.setPosition(100, 100)
.setSize(200, 100)
.setBarHeight(20)
.setItemHeight(20)
.addItems(l)
// .setType(ScrollableList.LIST) // currently supported DROPDOWN and LIST
;
}
void draw() {
background(240);
}
How can I get the dropdownlist to open up instead of down? I'm trying to place the list towards the lower edge of my screen. I could not find an option in the documentation.
Because of ControlP5's use of Java Generics inheritance is actually quite tricky in this case should
ScrollableListView'sdisplay()method be overriden:ScrollableList extends Controller< ScrollableList >PopUpScrollableListwould inheritController< ScrollableList >, notController< PopUpScrollableList >ScrollableListView'sdisplay()which belong toScrollableListwhich are eitherprivateorprotectedTLDR; @laancelot's suggestion to clone the library, modify the
ScrollableListView'sdisplay()method directly and recompiling the library sounds like the easier option compared subclassing to a custom scroll list.That being said, setting up an IDE and compiling a java library might not be the friendliest thing for a beginner, hence I can recommend a hacky workaround: simply shift the list's y position so it appears to be above instead of bellow:
It's not perfect visually, may be a potentially akward user experience, but it's the simplest option for this custom behaviour using ControlP5.
Alternatively it's worth looking at customising a different UI library or writin a custom list.
For the sake of argument, here's an modified version of the list example from theGuido library:
The code is a lot more verbose in the sketch, but could be moved to a separate GUI tab. Hopefully because it is simpler it can be manipulated easier than ControlP5 for custom behaviours.