controlP5
Class ScrollList

java.lang.Object
  extended by controlP5.ControllerGroup
      extended by controlP5.ControlGroup
          extended by controlP5.ScrollList
All Implemented Interfaces:
ControllerInterface, ControlListener, ControlP5Constants

public class ScrollList
extends ControlGroup
implements ControlListener

+Example
/**
  * 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, 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
 Button addItem(java.lang.String theName, int theValue)
          add an item to the scrollList.
 void addToXMLElement(ControlP5XMLElement theElement)
           
 void controlEvent(ControlEvent theEvent)
          ControlListener is an interface that can be implemented by a custom class.
 void hideScrollbar()
           
 boolean isScrollbarVisible()
           
 void removeItem(java.lang.String theItemName)
          remove an item from the scroll list.
 void scroll(float theValue)
          scroll the scrollList remotely.
 void setItemHeight(int theHeight)
           
 void showScrollbar()
           
 
Methods inherited from class controlP5.ControlGroup
activateEvent, addCloseButton, arrayValue, getBackgroundHeight, hideBar, isBarVisible, mousePressed, removeCloseButton, setArrayValue, setBackgroundColor, setBackgroundHeight, setBarHeight, showBar, stringValue, toString, value
 
Methods inherited from class controlP5.ControllerGroup
absolutePosition, add, addCanvas, addDrawable, captionLabel, close, color, continuousUpdateEvents, controller, disableCollapse, draw, enableCollapse, getAsXML, getColor, getHeight, getPickingColor, getTab, getWidth, getWindow, hide, id, init, isCollapse, isMoveable, isOpen, isUpdate, isVisible, isXMLsavable, keyEvent, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, name, open, parent, position, remove, remove, remove, removeCanvas, setColorActive, setColorBackground, setColorForeground, setColorLabel, setColorValue, setGroup, setGroup, setHeight, setId, setLabel, setMousePressed, setMoveable, setOpen, setPosition, setTab, setTab, setTab, setUpdate, setVisible, setWidth, show, update, updateAbsolutePosition, updateEvents, updateInternalEvents, valueLabel
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

hideScrollbar

public void hideScrollbar()

showScrollbar

public void showScrollbar()

isScrollbarVisible

public boolean isScrollbarVisible()

scroll

public void scroll(float theValue)
scroll the scrollList remotely. values must range from 0 to 1.

Parameters:
theValue -

setItemHeight

public void setItemHeight(int theHeight)

addItem

public Button addItem(java.lang.String theName,
                      int theValue)
add an item to the scrollList.

Parameters:
theName - String
theValue - int
Returns:
Button

removeItem

public void removeItem(java.lang.String theItemName)
remove an item from the scroll list.

Parameters:
theItemName - String

controlEvent

public void controlEvent(ControlEvent theEvent)
Description copied from interface: ControlListener
ControlListener is an interface that can be implemented by a custom class. add the controlListener to a controller with Controller.addListner()

Specified by:
controlEvent in interface ControlListener
Overrides:
controlEvent in class ControlGroup
Parameters:
theEvent - ControlEvent

addToXMLElement

public void addToXMLElement(ControlP5XMLElement theElement)
Specified by:
addToXMLElement in interface ControllerInterface
Overrides:
addToXMLElement in class ControlGroup
Parameters:
theElement - ControlP5XMLElement


processing library controlP5 by Andreas Schlegel. (c) 2010