|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.ObjectcontrolP5.ControllerGroup
controlP5.ControlGroup
controlP5.ScrollList
public class ScrollList
/**
* ControlP5 scrollList. depricated, use listBox.
*
* by andreas schlegel, 2009
*/
import controlP5.*;
ControlP5 controlP5;
ScrollList l;
void setup() {
size(400,400);
frameRate(30);
controlP5 = new ControlP5(this);
controlP5.setControlFont(new ControlFont(createFont("Times",20),14));
l = controlP5.addScrollList("myList",100,100,220,280);
l.setItemHeight(30);
l.setBarHeight(20);
l.captionLabel().toUpperCase(false);
l.captionLabel().set("something else");
l.captionLabel().style().marginTop = 4;
for(int i=0;i<40;i++) {
controlP5.Button b = l.addItem("a"+i,i);
b.setId(100 + i);
}
}
void controlEvent(ControlEvent theEvent) {
// ScrollList is of type ControlGroup.
// when an item in a scrollList is activated,
// 2 controlEvents will be broadcasted.
// the first one event is triggered from the ScrollList,
// the second one from the button that has been pressed
// inside the scrollList.
// to avoid an error message from controlP5, you
// need to check what type of item did trigger the
// event, either a controller or a group.
if(theEvent.isController()) {
// an event from a controller e.g. button
println(theEvent.controller().value()+" from "+theEvent.controller());
}
else if (theEvent.isGroup()) {
// an event from a group e.g. scrollList
println(theEvent.group().value()+" from "+theEvent.group());
}
}
void keyPressed() {
if(key=='r') {
l.removeItem("a"+int(random(40)) );
}
else if(key=='a') {
l.addItem("a"+int(random(40)), int(random(100)) );
}
}
void draw() {
background(0);
// 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
}
}
| Field Summary |
|---|
| Fields inherited from interface controlP5.ControlP5Constants |
|---|
acceptClassList, ACTION_BROADCAST, ACTION_ENTER, ACTION_LEAVE, ACTION_PRESSED, ACTION_RELEASED, ACTION_RELEASEDOUTSIDE, ACTIVE, ALT, ARC, ARRAY, BACKSPACE, BOOLEAN, BOTTOM, CENTER, CONTROL, controlEventClass, CUSTOM, DECREASE, DEFAULT, DELETE, DONE, DOWN, ELLIPSE, ENTER, ESCAPE, EVENT, eventMethod, FADEIN, FADEOUT, FIELD, FLOAT, HALF_PI, HIDE, HIGHLIGHT, HORIZONTAL, IDLE, IMAGE, INACTIVE, INCREASE, INTEGER, INVALID, KEYCONTROL, LEFT, LINE, LOAD, MENU, METHOD, MOVE, MULTIPLES, OVER, PI, PRESSED, PRINT, RELEASE, RESET, RIGHT, SAVE, SHIFT, SINGLE_COLUMN, SINGLE_ROW, SPRITE, STRING, SWITCH, SWITCH_BACK, SWITCH_FORE, TAB, TOP, TWO_PI, UP, VERBOSE, VERTICAL, WAIT |
| Method Summary | |
|---|---|
Button |
addItem(java.lang.String theName,
int theValue)
Deprecated. add an item to the scrollList. |
void |
controlEvent(ControlEvent theEvent)
Deprecated. ControlListener is an interface that can be implemented by a custom class. |
void |
hideScrollbar()
Deprecated. |
boolean |
isScrollbarVisible()
Deprecated. |
void |
removeItem(java.lang.String theItemName)
Deprecated. remove an item from the scroll list. |
void |
scroll(float theValue)
Deprecated. scroll the scrollList remotely. |
void |
setItemHeight(int theHeight)
Deprecated. |
void |
showScrollbar()
Deprecated. |
| Methods inherited from class controlP5.ControlGroup |
|---|
activateEvent, addCloseButton, addListener, getBackgroundHeight, getBarHeight, hideBar, info, isBarVisible, listenerSize, mousePressed, removeCloseButton, removeListener, setBackgroundColor, setBackgroundHeight, setBarHeight, showBar, stringValue, toString |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Method Detail |
|---|
public void hideScrollbar()
public void showScrollbar()
public boolean isScrollbarVisible()
public void scroll(float theValue)
theValue - public void setItemHeight(int theHeight)
public Button addItem(java.lang.String theName,
int theValue)
theName - StringtheValue - int
public void removeItem(java.lang.String theItemName)
theItemName - Stringpublic void controlEvent(ControlEvent theEvent)
ControlListener
controlEvent in interface ControlListenercontrolEvent in class ControlGrouptheEvent - ControlEvent
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||