Slider objects contain an indicator which can be moved by the user to set a value.
The function below creates a new Slider, so you need to save it in a variable (so you can use it later).
Function | Description |
Slider(orientation, lower, upper, start, function) | Creates a new Slider with orientation (HORIZONTAL or VERTICAL – default is HORIZONTAL), lower value (integer – default is 0), upper value (integer – default is 100), placing the indicator at start value (integer – default is half-way). When the indicator is moved, function (optional) is called automatically. If provided, this function should expect one parameter (i.e., the new value of the slider). |
For example, a slider may be created as follows:
slider1 = Slider(VERTICAL, 0, 127, 50, changeVolume)
where changeVolume is a function which expects one parameter, the new value of the slider. When the function is called, it may use this value to update the volume of some musical material, for instance.
Once a Slider has been created, it may be added to a Display specifying where to place its top-left corner.
d.add(slider1, 50, 50)
Additionally, you may use the following function to get its current value:
Function | Description |
slider1.getValue() | Returns the current value of the slider (an integer between lower and upper). |
slider1.setValue(value) | Sets the current value of the slider to value (an integer between lower and upper). |