controlP5
Class Numberbox

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

public class Numberbox
extends Controller

press the mouse inside a numberbox and move up and down to change the values of a numberbox. by default you increase and decrease numbers by dragging the mouse up and down. use setDirection(Controller.HORIZONTAL) to change the mouse control to left and right. Why do I get -1000000 as initial value when creating a numberbox without a default value? the value of a numberbox defaults back to its minValue, which is -1000000. either use a default value or link a variable to the numberbox - this is done by giving a float or int variable the same name as the numberbox. Use setMultiplier(float) to change the sensitivity of values increasing/decreasing, by default the multiplier is 1.

+Example
 /**
 * controlP5numberbox by andreas schlegel 
* an example to show how to use a numberbox to control
* variables and events.
*/ import controlP5.*; ControlP5 controlP5; int myColorBackground = color(0,0,0); public float numberboxValue = 100; void setup() { size(400,400); frameRate(25); controlP5 = new ControlP5(this); // add a numberbox controlP5.addNumberbox("numberbox",100,100,160,100,14); // add a second numberbox Numberbox n = controlP5.addNumberbox("numberboxValue",128,100,200,100,14); // set the sensitifity of the numberbox n.setMultiplier(0.1); // change the control direction to left/right n.setDirection(Controller.HORIZONTAL); } void draw() { background(myColorBackground); fill(numberboxValue); rect(0,0,width,100); } void numberbox(int theColor) { myColorBackground = color(theColor); println("a numberbox event. setting background to "+theColor); }

Field Summary
static int DOWN
           
static int LEFT
           
static int RIGHT
           
static int UP
           
 
Fields inherited from interface controlP5.ControlP5Constants
acceptClassList, ACTIVE, ALT, ARC, ARRAY, BACKSPACE, BOOLEAN, BOTTOM, CENTER, CONTROL, controlEventClass, CUSTOM, DECREASE, DEFAULT, DELETE, ELLIPSE, ENTER, ESCAPE, EVENT, eventMethod, FIELD, FLOAT, HALF_PI, HIDE, HIGHLIGHT, HORIZONTAL, IMAGE, INCREASE, INTEGER, INVALID, KEYCONTROL, LINE, LOAD, MENU, METHOD, MOVE, OVER, PI, PRESSED, PRINT, RELEASE, RESET, SAVE, SHIFT, SPRITE, STRING, SWITCH, SWITCH_BACK, SWITCH_FORE, TAB, TOP, TWO_PI, VERBOSE, VERTICAL
 
Constructor Summary
Numberbox(ControlP5 theControlP5, Tab theParent, java.lang.String theName, float theDefaultValue, int theX, int theY, int theWidth, int theHeight)
           
 
Method Summary
 void addToXMLElement(ControlP5XMLElement theElement)
           
 Controller linebreak()
           
 void mousePressed()
           
 void mouseReleased()
           
 void mouseReleasedOutside()
           
 float multiplier()
           
 void setDirection(int theValue)
          set the direction for changing the numberbox value when dragging the mouse.
 void setMultiplier(float theMultiplier)
           
 void setValue(float theValue)
          set the value of the numberbox.
 void update()
          updates the value of the controller without having to set the value explicitly.
 void updateDisplayMode(int theMode)
           
 void updateInternalEvents(processing.core.PApplet theApplet)
          TODO
 
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, listenerSize, lock, max, min, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, name, parent, plugTo, plugTo, position, remove, remove, removeBehavior, removeListener, setArrayValue, setBehavior, setBroadcast, setCaptionLabel, setColor, setColorActive, setColorBackground, setColorCaptionLabel, setColorForeground, setColorLabel, setColorValue, setColorValueLabel, setDecimalPrecision, setDefaultValue, setDisplay, setDisplay, setGroup, setGroup, setHeight, setId, setImage, setImage, setImages, setImages, setLabel, setLabelVisible, setLock, setMax, setMin, setMousePressed, setMoveable, setParent, setPosition, setSize, setSize, setSprite, setTab, setTab, setUpdate, setUserInteraction, setValueLabel, setVisible, setWidth, setWindow, setWindow, show, stringValue, toString, trigger, unlock, unplugFrom, unplugFrom, updateAbsolutePosition, updateEvents, updateSize, value, valueLabel
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LEFT

public static int LEFT

UP

public static int UP

RIGHT

public static int RIGHT

DOWN

public static int DOWN
Constructor Detail

Numberbox

public Numberbox(ControlP5 theControlP5,
                 Tab theParent,
                 java.lang.String theName,
                 float theDefaultValue,
                 int theX,
                 int theY,
                 int theWidth,
                 int theHeight)
Parameters:
theControlP5 - ControlP5
theParent - Tab
theName - String
theDefaultValue - float
theX - int
theY - int
theWidth - int
theHeight - int
Method Detail

updateInternalEvents

public void updateInternalEvents(processing.core.PApplet theApplet)
Description copied from class: Controller
TODO

Specified by:
updateInternalEvents in interface ControllerInterface
Overrides:
updateInternalEvents in class Controller
See Also:
ControllerInterface.updateInternalEvents

mousePressed

public void mousePressed()

mouseReleased

public void mouseReleased()

mouseReleasedOutside

public void mouseReleasedOutside()

setMultiplier

public void setMultiplier(float theMultiplier)

multiplier

public float multiplier()

setValue

public void setValue(float theValue)
set the value of the numberbox.

Specified by:
setValue in class Controller
Parameters:
theValue - float

setDirection

public void setDirection(int theValue)
set the direction for changing the numberbox value when dragging the mouse. by default this is up/down (VERTICAL), use setDirection(Controller.HORIZONTAL) to change to left/right or back with setDirection(Controller.VERTICAL).

Parameters:
theValue -

update

public void update()
Description copied from class: Controller
updates the value of the controller without having to set the value explicitly. update does not visually update the controller. the updating status can be set with setUpdate(true/false) and checked with isUpdate(). setUpdate ( )

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

linebreak

public Controller linebreak()
Overrides:
linebreak in class Controller

addToXMLElement

public void addToXMLElement(ControlP5XMLElement theElement)
Parameters:
theElement - ControlP5XMLElement

updateDisplayMode

public void updateDisplayMode(int theMode)


processing library controlP5 by Andreas Schlegel. (c) 2010