controlP5
Class MultiListButton

java.lang.Object
  extended by controlP5.Controller
      extended by controlP5.Button
          extended by controlP5.MultiListButton
All Implemented Interfaces:
CDrawable, ControllerInterface, ControlP5Constants, MultiListInterface

public class MultiListButton
extends Button
implements MultiListInterface

+Example
/**
 * ControlP5 MultiList
 * by andreas schlegel, 2009
 */

import controlP5.*;

ControlP5 controlP5;
MultiList l;

void setup() {
  size(400,400);
  frameRate(30);
  controlP5 = new ControlP5(this);
  
  // 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",0,10,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.controller("level21");
  cc.setHeight(40);
}


void controlEvent(ControlEvent theEvent) {
  println(theEvent.controller().name()+" = "+theEvent.value());  
  // uncomment the line below to remove a multilist item when clicked.
  // theEvent.controller().remove();
}


void draw() {
  background(0);
}

void keyPressed() {
  if(controlP5.controller("level23")!=null) {
    println("removing multilist button level23.");
    controlP5.controller("level23").remove();
  }
}

Field Summary
 
Fields inherited from interface controlP5.ControlP5Constants
acceptClassList, ACTIVE, ALT, ARC, ARRAY, BACKSPACE, BOOLEAN, BOTTOM, CENTER, CONTROL, controlEventClass, CUSTOM, DECREASE, DEFAULT, DELETE, DOWN, ELLIPSE, ENTER, ESCAPE, EVENT, eventMethod, FIELD, FLOAT, HALF_PI, HIDE, HIGHLIGHT, HORIZONTAL, IMAGE, INCREASE, INTEGER, INVALID, KEYCONTROL, LEFT, LINE, LOAD, MENU, METHOD, MOVE, OVER, PI, PRESSED, PRINT, RELEASE, RESET, RIGHT, SAVE, SHIFT, SPRITE, STRING, SWITCH, SWITCH_BACK, SWITCH_FORE, TAB, TOP, TWO_PI, UP, VERBOSE, VERTICAL
 
Method Summary
 MultiListButton add(java.lang.String theName, float theValue)
          add a new button to the sublist of this multilist button.
 void addToXMLElement(ControlP5XMLElement theElement)
          
 void close()
           
 void close(MultiListInterface theInterface)
           
 int getDirection()
           
 void mouseReleasedOutside()
          
 boolean observe()
           
 void open()
           
 void remove()
          remove a controller from controlP5.
 Controller setHeight(int theHeight)
          set the height of a multlist button.
 Controller setWidth(int theWidth)
          set the width of a multlist button.
 java.util.List<Controller> subelements()
           
 void updateLocation(float theX, float theY)
           
 void updateRect(float theX, float theY, float theW, float theH)
           
 
Methods inherited from class controlP5.Button
activateBy, booleanValue, mousePressed, mouseReleased, setOff, setOn, setSwitch, setValue, toString, update, updateDisplayMode
 
Methods inherited from class controlP5.Controller
absolutePosition, add, addListener, arrayValue, behavior, captionLabel, changeValue, color, continuousUpdateEvents, controlWindow, defaultValue, disableSprite, draw, enableSprite, getAsXML, getColor, getHeight, getPickingColor, getSprite, getTab, getWidth, getWindow, hide, id, init, isBroadcast, isInside, isLock, isMousePressed, isMoveable, isUpdate, isUserInteraction, isVisible, isXMLsavable, keyEvent, label, linebreak, listenerSize, lock, max, min, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, name, parent, plugTo, plugTo, position, remove, removeBehavior, removeListener, setArrayValue, setBehavior, setBroadcast, setCaptionLabel, setColor, setColorActive, setColorBackground, setColorCaptionLabel, setColorForeground, setColorLabel, setColorValue, setColorValueLabel, setDecimalPrecision, setDefaultValue, setDisplay, setDisplay, setGroup, setGroup, setId, setImage, setImage, setImages, setImages, setLabel, setLabelVisible, setLock, setMax, setMin, setMousePressed, setMoveable, setParent, setPosition, setSize, setSize, setSprite, setTab, setTab, setUpdate, setUserInteraction, setValueLabel, setVisible, setWindow, setWindow, show, stringValue, trigger, unlock, unplugFrom, unplugFrom, updateAbsolutePosition, updateEvents, updateInternalEvents, updateSize, value, valueLabel
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface controlP5.MultiListInterface
draw, name
 

Method Detail

remove

public void remove()
Description copied from class: Controller
remove a controller from controlP5.

Specified by:
remove in interface ControllerInterface
Overrides:
remove in class Controller

subelements

public java.util.List<Controller> subelements()
Specified by:
subelements in interface MultiListInterface
Returns:
Vector

getDirection

public int getDirection()
Specified by:
getDirection in interface MultiListInterface

updateRect

public void updateRect(float theX,
                       float theY,
                       float theW,
                       float theH)
Parameters:
theX - float
theY - float
theW - float
theH - float

updateLocation

public void updateLocation(float theX,
                           float theY)
Specified by:
updateLocation in interface MultiListInterface
Parameters:
theX - float
theY - float

setWidth

public Controller setWidth(int theWidth)
set the width of a multlist button.

Overrides:
setWidth in class Controller
Parameters:
theWidth - int

setHeight

public Controller setHeight(int theHeight)
set the height of a multlist button.

Overrides:
setHeight in class Controller
Parameters:
theHeight - int

add

public MultiListButton add(java.lang.String theName,
                           float theValue)
add a new button to the sublist of this multilist button.

Parameters:
theName - String
theValue - int
Returns:
MultiListButton

mouseReleasedOutside

public void mouseReleasedOutside()
Description copied from class: Button

Overrides:
mouseReleasedOutside in class Button

observe

public boolean observe()
Specified by:
observe in interface MultiListInterface
Parameters:
theMousePosition - CVector3f
Returns:
boolean

close

public void close(MultiListInterface theInterface)
Specified by:
close in interface MultiListInterface
Parameters:
theInterface - MultiListInterface

close

public void close()
Specified by:
close in interface MultiListInterface

open

public void open()
Specified by:
open in interface MultiListInterface

addToXMLElement

public void addToXMLElement(ControlP5XMLElement theElement)
Description copied from class: Button

Specified by:
addToXMLElement in interface ControllerInterface
Specified by:
addToXMLElement in interface MultiListInterface
Overrides:
addToXMLElement in class Button
Parameters:
theElement - ControlP5XMLElement


processing library controlP5 by Andreas Schlegel. (c) 2010