public class MultiListButton extends Button
/**
* ControlP5 MultiList
* by andreas schlegel, 2009
*
* broken with version 2.2.1+
*/
import controlP5.*;
ControlP5 controlP5;
MultiList l;
void setup() {
size(700,400);
frameRate(30);
controlP5 = new ControlP5(this);
// sorry, MultiList is currently broken.
// add a multiList to controlP5.
// elements of the list have default dimensions
// here, a width of 100 and a height of 12
l = controlP5.addMultiList("myList",20,20,100,12);
// create a multiListButton which we will use to
// add new buttons to the multilist
MultiListButton b;
b = l.add("level1",1);
// add items to a sublist of button "level1"
b.add("level11",11).setLabel("level1 item1");
b.add("level12",12).setLabel("level1 item2");
b = l.add("level2",2);
int cnt = 100;
// add some more sublists.
for(int i=0;i<10;i++) {
MultiListButton c = b.add("level2"+(i+1),20+i+1);
c.setLabel("level2 item"+(i+1));
c.setColorBackground(color(64 + 18*i,0,0));
if(i==4) {
// changing the width and the height of a button
// will be inherited by its sublists.
c.setWidth(100);
c.setHeight(20);
}
cnt++;
if(i==4) {
for(int j=0;j<10;j++) {
cnt++;
MultiListButton d;
d = c.add("level2"+i+""+j,250+j+1);
d.setLabel("level2 item"+(i+1)+" "+"item"+(j+1));
d.setColorBackground(color(64 + 18*j,(64 + 18*j)/2,0));
d.setId(cnt);
d.setWidth(200);
}
}
}
MultiListButton cc = (MultiListButton)controlP5.getController("level21");
cc.setHeight(40);
}
void controlEvent(ControlEvent theEvent) {
println(theEvent.getController().getName()+" = "+theEvent.value());
// uncomment the line below to remove a multilist item when clicked.
// theEvent.controller().remove();
}
void draw() {
background(0);
}
void keyPressed() {
if(controlP5.getController("level23")!=null) {
println("removing multilist button level23.");
controlP5.getController("level23").remove();
}
}
autoHeight, autoWidth
autoSpacing
acceptClassList, ACTION_BROADCAST, ACTION_CLICK, ACTION_DOUBLE_PRESS, ACTION_DRAG, ACTION_END_DRAG, ACTION_ENTER, ACTION_EXIT, ACTION_LEAVE, ACTION_MOVE, ACTION_PRESS, ACTION_PRESSED, ACTION_RELEASE, ACTION_RELEASE_OUTSIDE, ACTION_RELEASED, ACTION_RELEASEDOUTSIDE, ACTION_START_DRAG, ACTION_WHEEL, ACTIVE, ALL, ALT, AQUA, ARC, ARRAY, BACKSPACE, BASELINE, BITFONT, BLACK, BLUE, BOOLEAN, BOTTOM, BOTTOM_OUTSIDE, CAPTIONLABEL, CENTER, CHECKBOX, COMMANDKEY, CONTROL, controlEventClass, CUSTOM, DECREASE, DEFAULT, DELETE, delimiter, DONE, DOWN, DROPDOWN, ELLIPSE, ENTER, ESCAPE, EVENT, eventMethod, FADEIN, FADEOUT, FIELD, FLOAT, FUCHSIA, GRAY, GREEN, grixel, HALF_PI, HIDE, HIGHLIGHT, HORIZONTAL, IDLE, IMAGE, INACTIVE, INCREASE, INTEGER, INVALID, J2D, JSON, KEYCONTROL, LEFT, LEFT_OUTSIDE, LIME, LINE, LIST, LOAD, MAROON, MENU, METHOD, MOVE, MULTI, MULTIPLES, NAVY, OLIVE, ORANGE, OVER, P2D, P3D, pathdelimiter, PI, PRESS, PRESSED, PRINT, PURPLE, RED, RELEASE, RELEASED, RESET, RIGHT, RIGHT_OUTSIDE, SAVE, SERIALIZED, SHIFT, SILVER, SINGLE, SINGLE_COLUMN, SINGLE_ROW, SPRITE, standard56, standard58, STRING, SWITCH, SWITCH_BACK, SWITCH_FORE, synt24, TAB, TEAL, THEME_A, THEME_CP52014, THEME_CP5BLUE, THEME_GREY, THEME_RED, THEME_RETRO, TOP, TOP_OUTSIDE, TRANSITION_WAIT_FADEIN, TREE, TWO_PI, UP, VALUELABEL, VERBOSE, VERTICAL, WAIT, WHITE, YELLOW
Modifier and Type | Method and Description |
---|---|
MultiListButton |
add(java.lang.String theName,
float theValue)
add a new button to the sublist of this multilist button.
|
void |
close() |
void |
close(controlP5.MultiListInterface theInterface) |
void |
draw(processing.core.PGraphics theGraphics) |
int |
getDirection() |
void |
mouseReleasedOutside() |
boolean |
observe() |
void |
open() |
void |
remove()
removes a controller from controlP5.
|
MultiListButton |
setHeight(int theHeight)
set the height of a multlist button.
|
MultiListButton |
setWidth(int theWidth)
set the width of a multlist button.
|
MultiListButton |
toUpperCase(boolean theValue) |
void |
updateLocation(float theX,
float theY) |
void |
updateRect(float theX,
float theY,
float theW,
float theH) |
activateBy, getBooleanValue, getInfo, isOn, isPressed, isSwitch, mousePressed, mouseReleased, setOff, setOn, setSwitch, setValue, toString, update, updateDisplayMode, updateViewMode
add, addCallback, addListener, addListenerFor, align, bringToFront, bringToFront, changeValue, continuousUpdateEvents, draw, getAbsolutePosition, getAddress, getArrayValue, getArrayValue, getBehavior, getCaptionLabel, getColor, getControllerPlugList, getControlWindow, getDecimalPrecision, getDefaultValue, getHeight, getId, getLabel, getMax, getMin, getName, getParent, getPickingColor, getPointer, getPosition, getProperty, getProperty, getStringValue, getTab, getValue, getValueLabel, getView, getWidth, getWindow, hide, init, isActive, isBroadcast, isInside, isLabelVisible, isListening, isLock, isMouseOver, isMousePressed, isMoveable, isUpdate, isUserInteraction, isVisible, keyEvent, linebreak, listen, listenerSize, lock, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, onChange, onClick, onDoublePress, onDrag, onDraw, onEndDrag, onEnter, onLeave, onMove, onPress, onRelease, onReleaseOutside, onStartDrag, onWheel, plugTo, plugTo, plugTo, plugTo, registerProperty, registerProperty, registerTooltip, remove, removeBehavior, removeCallback, removeCallback, removeListener, removeListenerFor, removeListenersFor, removeProperty, removeProperty, set, setAbsolutePosition, setAddress, setArrayValue, setArrayValue, setBehavior, setBroadcast, setCaptionLabel, setColor, setColorActive, setColorBackground, setColorCaptionLabel, setColorForeground, setColorLabel, setColorValue, setColorValueLabel, setDecimalPrecision, setDefaultValue, setGroup, setGroup, setId, setImage, setImage, setImages, setImages, setImages, setLabel, setLabelVisible, setLock, setMax, setMin, setMouseOver, setMousePressed, setMoveable, setParent, setPosition, setPosition, setSize, setSize, setStringValue, setTab, setTab, setUpdate, setUserInteraction, setValueLabel, setValueSelf, setView, setView, setVisible, show, unlock, unplugFrom, unplugFrom, unregisterTooltip, updateAbsolutePosition, updateEvents, updateInternalEvents, updateSize, x, y
public MultiListButton add(java.lang.String theName, float theValue)
theName
- StringtheValue
- intpublic void close()
public void close(controlP5.MultiListInterface theInterface)
public int getDirection()
public void mouseReleasedOutside()
mouseReleasedOutside
in class Button
public boolean observe()
public void open()
public void remove()
Controller
remove
in interface ControllerInterface<Button>
remove
in class Controller<Button>
public MultiListButton setHeight(int theHeight)
setHeight
in class Controller<Button>
theHeight
- intpublic MultiListButton setWidth(int theWidth)
setWidth
in class Controller<Button>
theWidth
- intpublic MultiListButton toUpperCase(boolean theValue)
public void updateLocation(float theX, float theY)
public void updateRect(float theX, float theY, float theW, float theH)
public void draw(processing.core.PGraphics theGraphics)
processing library controlP5 by Andreas Schlegel. (c) 2006-2015