controlp5
controlp5 copied to clipboard
Scrollable List one on top of the other if I had two lists
Hi there,
I have multiple scrollable lists in my project, and I arrange them vertically. However, when I do that, the list on the bottom will show on top of the upper list. is there a way to fix it? Or I have to arrange them horizontally.
Thanks a lot.
Will Controller.bringToFront() work for you here? For example
import controlP5.*;
import java.util.*;
ControlP5 cp5;
void setup() {
size(800, 400);
List l = Arrays.asList("a", "b", "c", "d", "e", "f", "g", "h");
cp5 = new ControlP5(this);
CallbackListener toFront = new CallbackListener() {
public void controlEvent(CallbackEvent theEvent) {
theEvent.getController().bringToFront();
// ((ScrollableList)theEvent.getController()).open();
}
};
ScrollableList s1 = cp5
.addScrollableList("s1")
.setPosition(10, 10)
.setSize(200, 100)
.setBarHeight(20)
.setItemHeight(20)
.addItems(l)
.setBackgroundColor(color(0))
.onEnter(toFront)
.close()
;
ScrollableList s2 = cp5
.addScrollableList("s2")
.setPosition(50, 30)
.setSize(200, 100)
.setBarHeight(20)
.setItemHeight(20)
.addItems(l)
.setBackgroundColor(color(0))
.onEnter(toFront)
.close()
;
ScrollableList s3 = cp5
.addScrollableList("s3")
.setPosition(100, 50)
.setSize(200, 100)
.setBarHeight(20)
.setItemHeight(20)
.addItems(l)
.setBackgroundColor(color(0))
.onEnter(toFront)
.close()
;
}
void draw() {
background(220);
}