Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
piergiu
piergiu's Profile
1
Posts
1
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
Use controlP5 listBox to select string
[3 Replies]
29-Jun-2010 03:32 AM
Forum:
Contributed Library Questions
I've this listbox (the file list.txt is a list of about 1000 names):
import controlP5.*;
ControlP5 controlP5;
ListBox l;
ArrayList testoA = new ArrayList();
void setup( ) {
size(470, 295);
controlP5 = new ControlP5(this);
l = controlP5.addListBox("myList",20,40,80,240);
l.setItemHeight(15);
l.setBarHeight(15);
l.captionLabel().toUpperCase(true);
l.captionLabel().set("SELECT A NAME");
l.captionLabel().style().marginTop = 3;
l.valueLabel().style().marginTop = 3; // the +/- sign
//l.setBackgroundColor(color(100,0,0));
l.setColorBackground(color(255,128));
l.setColorActive(color(255,0,0,128));
String[] lines = loadStrings("list.txt");
for( int i = 0; i < lines.length; i++){
String[] tokens = lines[i].toLowerCase().split(" ");
for (int k = 0; k < tokens.length; k++){
testoA.add(tokens[k]);
l.addItem(tokens[k], k);
}
}
}
void controlEvent(ControlEvent theEvent) {
if (theEvent.isGroup()) {
// an event from a group e.g. scrollList
println(theEvent.group().value() +" from "+theEvent.group());
}
}
void draw(){
background(0);
text (tokens[ceil(theEvent.group().value())]);
}
there's a way to use the "label" of the listbox as text in void draw?
thanks
«Prev
Next »
Moderate user : piergiu
Forum