controlP5

## Class ScrollableList

- java.lang.Object
- - controlP5.Controller<ScrollableList>
  - - controlP5.ScrollableList

- All Implemented Interfaces:
    CDrawable, ControllerInterface<ScrollableList>, ControlListener, ControlP5Constants

      public class ScrollableList
      extends Controller<ScrollableList>
      implements ControlListener

  A ScrollableList is a list of vertically aligned items which can be scrolled if required.
  +Example
    `

        /**
         * ControlP5 ScrollableList
         *
         * replaces DropdownList and and ListBox.
         * List can be scrolled by dragging the list or using the scroll-wheel.
         *
         * by Andreas Schlegel, 2014
         * www.sojamo.de/libraries/controlp5
         *
         */

        import controlP5.*;
        import java.util.*;

        ControlP5 cp5;

        void setup() {
          size(400, 400);
          cp5 = new ControlP5(this);
          List l = Arrays.asList("a", "b", "c", "d", "e", "f", "g", "h");
          /* add a ScrollableList, by default it behaves like a DropdownList */
          cp5.addScrollableList("dropdown")
             .setPosition(100, 100)
             .setSize(200, 100)
             .setBarHeight(20)
             .setItemHeight(20)
             .addItems(l)
             // .setType(ScrollableList.LIST) // currently supported DROPDOWN and LIST
             ;

        }

        void draw() {
          background(240);
        }

        void dropdown(int n) {
          /* request the selected item based on index n */
          println(n, cp5.get(ScrollableList.class, "dropdown").getItem(n));

          /* here an item is stored as a Map  with the following key-value pairs:
           * name, the given name of the item
           * text, the given text of the item by default the same as name
           * value, the given value of the item, can be changed by using .getItem(n).put("value", "abc"); a value here is of type Object therefore can be anything
           * color, the given color of the item, how to change, see below
           * view, a customizable view, is of type CDrawable
           */

           CColor c = new CColor();
          c.setBackground(color(255,0,0));
          cp5.get(ScrollableList.class, "dropdown").getItem(n).put("color", c);

        }

        void keyPressed() {
          switch(key) {
            case('1'):
            /* make the ScrollableList behave like a ListBox */
            cp5.get(ScrollableList.class, "dropdown").setType(ControlP5.LIST);
            break;
            case('2'):
            /* make the ScrollableList behave like a DropdownList */
            cp5.get(ScrollableList.class, "dropdown").setType(ControlP5.DROPDOWN);
            break;
            case('3'):
            /*change content of the ScrollableList */
            List l = Arrays.asList("a-1", "b-1", "c-1", "d-1", "e-1", "f-1", "g-1", "h-1", "i-1", "j-1", "k-1");
            cp5.get(ScrollableList.class, "dropdown").setItems(l);
            break;
            case('4'):
            /* remove an item from the ScrollableList */
            cp5.get(ScrollableList.class, "dropdown").removeItem("k-1");
            break;
            case('5'):
            /* clear the ScrollableList */
            cp5.get(ScrollableList.class, "dropdown").clear();
            break;
          }
        }
        /*
        a list of all methods available for the ScrollableList Controller
        use ControlP5.printPublicMethodsFor(ScrollableList.class);
        to print the following list into the console.

        You can find further details about class ScrollableList in the javadoc.

        Format:
        ClassName : returnType methodName(parameter type)

        controlP5.Controller : CColor getColor()
        controlP5.Controller : ControlBehavior getBehavior()
        controlP5.Controller : ControlWindow getControlWindow()
        controlP5.Controller : ControlWindow getWindow()
        controlP5.Controller : ControllerProperty getProperty(String)
        controlP5.Controller : ControllerProperty getProperty(String, String)
        controlP5.Controller : ControllerView getView()
        controlP5.Controller : Label getCaptionLabel()
        controlP5.Controller : Label getValueLabel()
        controlP5.Controller : List getControllerPlugList()
        controlP5.Controller : Pointer getPointer()
        controlP5.Controller : ScrollableList addCallback(CallbackListener)
        controlP5.Controller : ScrollableList addListener(ControlListener)
        controlP5.Controller : ScrollableList addListenerFor(int, CallbackListener)
        controlP5.Controller : ScrollableList align(int, int, int, int)
        controlP5.Controller : ScrollableList bringToFront()
        controlP5.Controller : ScrollableList bringToFront(ControllerInterface)
        controlP5.Controller : ScrollableList hide()
        controlP5.Controller : ScrollableList linebreak()
        controlP5.Controller : ScrollableList listen(boolean)
        controlP5.Controller : ScrollableList lock()
        controlP5.Controller : ScrollableList onChange(CallbackListener)
        controlP5.Controller : ScrollableList onClick(CallbackListener)
        controlP5.Controller : ScrollableList onDoublePress(CallbackListener)
        controlP5.Controller : ScrollableList onDrag(CallbackListener)
        controlP5.Controller : ScrollableList onDraw(ControllerView)
        controlP5.Controller : ScrollableList onEndDrag(CallbackListener)
        controlP5.Controller : ScrollableList onEnter(CallbackListener)
        controlP5.Controller : ScrollableList onLeave(CallbackListener)
        controlP5.Controller : ScrollableList onMove(CallbackListener)
        controlP5.Controller : ScrollableList onPress(CallbackListener)
        controlP5.Controller : ScrollableList onRelease(CallbackListener)
        controlP5.Controller : ScrollableList onReleaseOutside(CallbackListener)
        controlP5.Controller : ScrollableList onStartDrag(CallbackListener)
        controlP5.Controller : ScrollableList onWheel(CallbackListener)
        controlP5.Controller : ScrollableList plugTo(Object)
        controlP5.Controller : ScrollableList plugTo(Object, String)
        controlP5.Controller : ScrollableList plugTo(Object[])
        controlP5.Controller : ScrollableList plugTo(Object[], String)
        controlP5.Controller : ScrollableList registerProperty(String)
        controlP5.Controller : ScrollableList registerProperty(String, String)
        controlP5.Controller : ScrollableList registerTooltip(String)
        controlP5.Controller : ScrollableList removeBehavior()
        controlP5.Controller : ScrollableList removeCallback()
        controlP5.Controller : ScrollableList removeCallback(CallbackListener)
        controlP5.Controller : ScrollableList removeListener(ControlListener)
        controlP5.Controller : ScrollableList removeListenerFor(int, CallbackListener)
        controlP5.Controller : ScrollableList removeListenersFor(int)
        controlP5.Controller : ScrollableList removeProperty(String)
        controlP5.Controller : ScrollableList removeProperty(String, String)
        controlP5.Controller : ScrollableList setArrayValue(float[])
        controlP5.Controller : ScrollableList setArrayValue(int, float)
        controlP5.Controller : ScrollableList setBehavior(ControlBehavior)
        controlP5.Controller : ScrollableList setBroadcast(boolean)
        controlP5.Controller : ScrollableList setCaptionLabel(String)
        controlP5.Controller : ScrollableList setColor(CColor)
        controlP5.Controller : ScrollableList setColorActive(int)
        controlP5.Controller : ScrollableList setColorBackground(int)
        controlP5.Controller : ScrollableList setColorCaptionLabel(int)
        controlP5.Controller : ScrollableList setColorForeground(int)
        controlP5.Controller : ScrollableList setColorLabel(int)
        controlP5.Controller : ScrollableList setColorValue(int)
        controlP5.Controller : ScrollableList setColorValueLabel(int)
        controlP5.Controller : ScrollableList setDecimalPrecision(int)
        controlP5.Controller : ScrollableList setDefaultValue(float)
        controlP5.Controller : ScrollableList setHeight(int)
        controlP5.Controller : ScrollableList setId(int)
        controlP5.Controller : ScrollableList setImage(PImage)
        controlP5.Controller : ScrollableList setImage(PImage, int)
        controlP5.Controller : ScrollableList setImages(PImage, PImage, PImage)
        controlP5.Controller : ScrollableList setImages(PImage, PImage, PImage, PImage)
        controlP5.Controller : ScrollableList setLabel(String)
        controlP5.Controller : ScrollableList setLabelVisible(boolean)
        controlP5.Controller : ScrollableList setLock(boolean)
        controlP5.Controller : ScrollableList setMax(float)
        controlP5.Controller : ScrollableList setMin(float)
        controlP5.Controller : ScrollableList setMouseOver(boolean)
        controlP5.Controller : ScrollableList setMoveable(boolean)
        controlP5.Controller : ScrollableList setPosition(float, float)
        controlP5.Controller : ScrollableList setPosition(float[])
        controlP5.Controller : ScrollableList setSize(PImage)
        controlP5.Controller : ScrollableList setSize(int, int)
        controlP5.Controller : ScrollableList setStringValue(String)
        controlP5.Controller : ScrollableList setUpdate(boolean)
        controlP5.Controller : ScrollableList setValue(float)
        controlP5.Controller : ScrollableList setValueLabel(String)
        controlP5.Controller : ScrollableList setValueSelf(float)
        controlP5.Controller : ScrollableList setView(ControllerView)
        controlP5.Controller : ScrollableList setVisible(boolean)
        controlP5.Controller : ScrollableList setWidth(int)
        controlP5.Controller : ScrollableList show()
        controlP5.Controller : ScrollableList unlock()
        controlP5.Controller : ScrollableList unplugFrom(Object)
        controlP5.Controller : ScrollableList unplugFrom(Object[])
        controlP5.Controller : ScrollableList unregisterTooltip()
        controlP5.Controller : ScrollableList update()
        controlP5.Controller : ScrollableList updateSize()
        controlP5.Controller : String getAddress()
        controlP5.Controller : String getInfo()
        controlP5.Controller : String getName()
        controlP5.Controller : String getStringValue()
        controlP5.Controller : String toString()
        controlP5.Controller : Tab getTab()
        controlP5.Controller : boolean isActive()
        controlP5.Controller : boolean isBroadcast()
        controlP5.Controller : boolean isInside()
        controlP5.Controller : boolean isLabelVisible()
        controlP5.Controller : boolean isListening()
        controlP5.Controller : boolean isLock()
        controlP5.Controller : boolean isMouseOver()
        controlP5.Controller : boolean isMousePressed()
        controlP5.Controller : boolean isMoveable()
        controlP5.Controller : boolean isUpdate()
        controlP5.Controller : boolean isVisible()
        controlP5.Controller : float getArrayValue(int)
        controlP5.Controller : float getDefaultValue()
        controlP5.Controller : float getMax()
        controlP5.Controller : float getMin()
        controlP5.Controller : float getValue()
        controlP5.Controller : float[] getAbsolutePosition()
        controlP5.Controller : float[] getArrayValue()
        controlP5.Controller : float[] getPosition()
        controlP5.Controller : int getDecimalPrecision()
        controlP5.Controller : int getHeight()
        controlP5.Controller : int getId()
        controlP5.Controller : int getWidth()
        controlP5.Controller : int listenerSize()
        controlP5.Controller : void remove()
        controlP5.Controller : void setView(ControllerView, int)
        controlP5.ScrollableList : List getItems()
        controlP5.ScrollableList : Map getItem(String)
        controlP5.ScrollableList : Map getItem(int)
        controlP5.ScrollableList : ScrollableList addItem(String, Object)
        controlP5.ScrollableList : ScrollableList addItems(List)
        controlP5.ScrollableList : ScrollableList addItems(Map)
        controlP5.ScrollableList : ScrollableList addItems(String[])
        controlP5.ScrollableList : ScrollableList clear()
        controlP5.ScrollableList : ScrollableList close()
        controlP5.ScrollableList : ScrollableList open()
        controlP5.ScrollableList : ScrollableList removeItem(String)
        controlP5.ScrollableList : ScrollableList removeItems(List)
        controlP5.ScrollableList : ScrollableList setBackgroundColor(int)
        controlP5.ScrollableList : ScrollableList setBarHeight(int)
        controlP5.ScrollableList : ScrollableList setBarVisible(boolean)
        controlP5.ScrollableList : ScrollableList setItemHeight(int)
        controlP5.ScrollableList : ScrollableList setItems(List)
        controlP5.ScrollableList : ScrollableList setItems(Map)
        controlP5.ScrollableList : ScrollableList setItems(String[])
        controlP5.ScrollableList : ScrollableList setOpen(boolean)
        controlP5.ScrollableList : ScrollableList setScrollSensitivity(float)
        controlP5.ScrollableList : ScrollableList setType(int)
        controlP5.ScrollableList : boolean isBarVisible()
        controlP5.ScrollableList : boolean isOpen()
        controlP5.ScrollableList : int getBackgroundColor()
        controlP5.ScrollableList : int getBarHeight()
        controlP5.ScrollableList : int getHeight()
        controlP5.ScrollableList : void controlEvent(ControlEvent)
        controlP5.ScrollableList : void keyEvent(KeyEvent)
        controlP5.ScrollableList : void setDirection(int)
        controlP5.ScrollableList : void updateItemIndexOffset()
        java.lang.Object : String toString()
        java.lang.Object : boolean equals(Object)

        created: 2015/03/24 12:21:22

        */

    `

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `ScrollableList.ScrollableListView`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `CHECKBOX`
    `static int` | `DROPDOWN`
    `static int` | `LIST`
    `static int` | `TREE`

    - ### Fields inherited from class controlP5.Controller

      `autoHeight, autoSpacing, autoWidth`

    - ### Fields inherited from interface controlP5.ControlP5Constants

      `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, COMMANDKEY, CONTROL, controlEventClass, CUSTOM, DECREASE, DEFAULT, DELETE, delimiter, DONE, DOWN, 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, 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, TWO_PI, UP, VALUELABEL, VERBOSE, VERTICAL, WAIT, WHITE, YELLOW`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ScrollableList(ControlP5 theControlP5, java.lang.String theName)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `ScrollableList` | `addItem(java.lang.String theName, java.lang.Object theValue)`
    `ScrollableList` | `addItems(java.util.List<java.lang.String> theItems)`
    `ScrollableList` | `addItems(java.util.Map<java.lang.String,java.lang.Object> theItems)`
    `ScrollableList` | `addItems(java.lang.String[] theItems)`
    `ScrollableList` | `clear()`
    `ScrollableList` | `close()`
    `void` | `controlEvent(ControlEvent theEvent)` controlEvent is called by controlP5's ControlBroadcaster to inform available listeners about value changes.
    `int` | `getBackgroundColor()`
    `int` | `getBarHeight()`
    `int` | `getHeight()`
    `java.util.Map<java.lang.String,java.lang.Object>` | `getItem(int theIndex)`
    `java.util.Map<java.lang.String,java.lang.Object>` | `getItem(java.lang.String theName)`
    `java.util.List` | `getItems()`
    `boolean` | `isBarVisible()`
    `boolean` | `isOpen()`
    `void` | `keyEvent(processing.event.KeyEvent theKeyEvent)`
    `ScrollableList` | `open()`
    `ScrollableList` | `removeItem(java.lang.String theName)`
    `ScrollableList` | `removeItems(java.util.List<java.lang.String> theItems)`
    `ScrollableList` | `setBackgroundColor(int theColor)`
    `ScrollableList` | `setBarHeight(int theHeight)`
    `ScrollableList` | `setBarVisible(boolean b)`
    `void` | `setDirection(int theDirection)`
    `ScrollableList` | `setItemHeight(int theHeight)`
    `ScrollableList` | `setItems(java.util.List<java.lang.String> theItems)`
    `ScrollableList` | `setItems(java.util.Map<java.lang.String,java.lang.Object> theItems)`
    `ScrollableList` | `setItems(java.lang.String[] theItems)`
    `ScrollableList` | `setOpen(boolean b)`
    `ScrollableList` | `setScrollSensitivity(float theSensitivity)`
    `ScrollableList` | `setType(int theType)`
    `ScrollableList` | `setValue(float theValue)`
    `ScrollableList` | `updateDisplayMode(int theMode)`
    `void` | `updateItemIndexOffset()`

    - ### Methods inherited from class controlP5.Controller

      `add, addCallback, addListener, addListenerFor, align, bringToFront, bringToFront, changeValue, continuousUpdateEvents, draw, getAbsolutePosition, getAddress, getArrayValue, getArrayValue, getBehavior, getCaptionLabel, getColor, getControllerPlugList, getControlWindow, getDecimalPrecision, getDefaultValue, getId, getInfo, 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, 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, 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, setFont, setFont, setGroup, setGroup, setHeight, 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, setWidth, show, toString, unlock, unplugFrom, unplugFrom, unregisterTooltip, update, updateAbsolutePosition, updateEvents, updateInternalEvents, updateSize, x, y`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### CHECKBOX

          public static final int CHECKBOX

      See Also:
        Constant Field Values

    - #### DROPDOWN

          public static final int DROPDOWN

      See Also:
        Constant Field Values

    - #### LIST

          public static final int LIST

      See Also:
        Constant Field Values

    - #### TREE

          public static final int TREE

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### ScrollableList

          public ScrollableList(ControlP5 theControlP5,
                                java.lang.String theName)

  - ### Method Detail

    - #### addItem

          public ScrollableList addItem(java.lang.String theName,
                                        java.lang.Object theValue)

    - #### addItems

          public ScrollableList addItems(java.util.List<java.lang.String> theItems)

    - #### addItems

          public ScrollableList addItems(java.util.Map<java.lang.String,java.lang.Object> theItems)

    - #### addItems

          public ScrollableList addItems(java.lang.String[] theItems)

    - #### clear

          public ScrollableList clear()

    - #### close

          public ScrollableList close()

    - #### controlEvent

          public void controlEvent(ControlEvent theEvent)

      Description copied from interface: `ControlListener`
      controlEvent is called by controlP5's ControlBroadcaster to inform available listeners about value changes. Use the CallbackListener to get informed when actions such as pressed, release, drag, etc are performed.
      Specified by:
        `controlEvent` in interface `ControlListener`
      Parameters:
        `theEvent` - ControlEvent
      See Also:
        `CallbackListener`, `CallbackEvent`

    - #### getBackgroundColor

          public int getBackgroundColor()

    - #### getBarHeight

          public int getBarHeight()

    - #### getHeight

          public int getHeight()

      Specified by:
        `getHeight` in interface `ControllerInterface<ScrollableList>`
      Overrides:
        `getHeight` in class `Controller<ScrollableList>`
      Returns:
        int

    - #### getItem

          public java.util.Map<java.lang.String,java.lang.Object> getItem(int theIndex)

    - #### getItem

          public java.util.Map<java.lang.String,java.lang.Object> getItem(java.lang.String theName)

    - #### getItems

          public java.util.List getItems()

    - #### isBarVisible

          public boolean isBarVisible()

    - #### isOpen

          public boolean isOpen()

    - #### keyEvent

          public void keyEvent(processing.event.KeyEvent theKeyEvent)

      Specified by:
        `keyEvent` in interface `ControllerInterface<ScrollableList>`
      Overrides:
        `keyEvent` in class `Controller<ScrollableList>`

    - #### open

          public ScrollableList open()

    - #### removeItem

          public ScrollableList removeItem(java.lang.String theName)

    - #### removeItems

          public ScrollableList removeItems(java.util.List<java.lang.String> theItems)

    - #### setBackgroundColor

          public ScrollableList setBackgroundColor(int theColor)

    - #### setBarHeight

          public ScrollableList setBarHeight(int theHeight)

    - #### setBarVisible

          public ScrollableList setBarVisible(boolean b)

    - #### setDirection

          public void setDirection(int theDirection)

    - #### setItemHeight

          public ScrollableList setItemHeight(int theHeight)

    - #### setItems

          public ScrollableList setItems(java.util.List<java.lang.String> theItems)

    - #### setItems

          public ScrollableList setItems(java.util.Map<java.lang.String,java.lang.Object> theItems)

    - #### setItems

          public ScrollableList setItems(java.lang.String[] theItems)

    - #### setOpen

          public ScrollableList setOpen(boolean b)

    - #### setScrollSensitivity

          public ScrollableList setScrollSensitivity(float theSensitivity)

    - #### setType

          public ScrollableList setType(int theType)

    - #### setValue

          public ScrollableList setValue(float theValue)

      Specified by:
        `setValue` in interface `ControllerInterface<ScrollableList>`
      Overrides:
        `setValue` in class `Controller<ScrollableList>`
      Parameters:
        `theValue` - float

    - #### updateDisplayMode

          public ScrollableList updateDisplayMode(int theMode)

    - #### updateItemIndexOffset

          public void updateItemIndexOffset()

processing library controlP5 by Andreas Schlegel. (c) 2006-2016