We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello, I have questions about the ControlP5 library. Yesterday, I've found this library with a scrollable list example:
import controlP5.*;
import java.util.*;
String[] listItems = new String[5];
ControlP5 cp5;
void setup() {
size(400, 400);
surface.setResizable(true);
listItems[0] = "5130";
listItems[1] = "5131";
listItems[2] = "5150";
listItems[3] = "5170";
listItems[4] = "9591";
cp5 = new ControlP5(this);
List l = Arrays.asList(listItems);
/* add a ScrollableList, by default it behaves like a DropdownList */
cp5.addScrollableList("dropdown")
.setPosition(10, 10)
.setSize(width-20, height-20)
.setBarHeight(50)
.setItemHeight(20)
.addItems(l)
.setType(ScrollableList.LIST) // currently supported DROPDOWN and LIST
;
}
void draw() {
background(240);
}
void dropdown(int n) {
CColor c = new CColor();
c.setBackground(color(255,0,0));
cp5.get(ScrollableList.class, "dropdown").getItem(n).put("color", c);
}
(I've removed some code from the example which was un-necessary for me) Now, I have this questions:
Thanks in advance, Daantje
Answers
No one knows?
hi.
use setSize inside draw
cp5.get(Controller.class, "dropdown").setSize(width-20, height-20);
use the setColor options when you create the ScrollableList
you can file an issue at github.com/sojamo/controlp5/issues as an enhancement
Hey, i got a COMport list. Like this.
String[] portNames = SerialPortList.getPortNames(); List Ports = Arrays.asList(portNames); sbCOM = cp5.addScrollableList("ComList");
How can i "Close Port" added at the end of the ArrayList?. Regards Willi
I have resolve himself. `
String[] listItems = new String[Serial.list().length+1];
for (int i = 0; i < Serial.list().length; i++) { printArray(Serial.list());
listItems[i] = Serial.list()[i]; println(listItems[i] + " "+i); }
listItems[Serial.list().length] = "Close Port"; `