We are about to switch to a new forum software. Until then we have removed the registration on this forum.
import controlP5.*;
ControlP5 cp5;
ListBox l;
int cnt = 0;
void setup() {
size(700, 400);
ControlP5.printPublicMethodsFor(ListBox.class);
cp5 = new ControlP5(this);
l = cp5.addListBox("myList")
.setPosition(100, 100)
.setSize(120, 120)
.setItemHeight(15)
.setBarHeight(15)
.setColorBackground(color(40, 128))
.setColorActive(color(255, 128))
;
l.captionLabel().toUpperCase(true);
l.captionLabel().set("A Listbox");
l.captionLabel().setColor(0xffff0000);
l.captionLabel().style().marginTop = 3;
l.valueLabel().style().marginTop = 3;
for (int i=0;i<80;i++) {
ListBoxItem lbi = l.addItem("item "+i, i);
lbi.setColorBackground(0xffff0000);
}
}
void controlEvent(ControlEvent theEvent) {
// ListBox is if type ControlGroup.
// 1 controlEvent will be executed, where the event
// originates from a ControlGroup. therefore
// you need to check the Event with
// if (theEvent.isGroup())
// to avoid an error message from controlP5.
if (theEvent.isGroup()) {
// an event from a group e.g. scrollList
println(theEvent.group().value()+" from "+theEvent.group());
}
if(theEvent.isGroup() && theEvent.name().equals("myList")){
int test = (int)theEvent.group().value();
println("test "+test);
}
}
void draw() {
background(128);
// scroll the scroll List according to the mouseX position
// when holding down SPACE.
if (keyPressed && key==' ') {
//l.scroll(mouseX/((float)width)); // scroll taks values between 0 and 1
}
if (keyPressed && key==' ') {
l.setWidth(mouseX);
}
}
Answers
[-O<
:-/ What do you mean the ListBox is displayed upwards? Is this the code that this happened in, and is it glitching out, somehow? Because when I ran your code, it seemed to be fine.
-- MenteCode.
I want the window then appears up!! . How? ~O)
In all of the commands listed using this:
I have not found a single method that would modify opening direction.
I don't think you can do that in ControlP5. Unless you're one of those people who can make a method in Processing, and use that method as part of ControlP5 (not even sure if THAT's possible). :-?