# Slider¶

structure Slider

Slider widgets are created via BOX:ADDHSLIDER and BOX:ADDVSLIDER.

A Slider is a widget that holds the value of a Scalar that the user can adjust by moving a sliding marker along a line.

It is suited for real-number varying values, but not well suited for integer values.

Suffix Type Description
Every suffix of WIDGET
VALUE scalar The current value. Initially set to MIN.
ONCHANGE KOSDelegate (Scalar) Your function called whenever the VALUE changes.
MIN scalar The minimum value (leftmost on horizontal slider).
MAX scalar The maximum value (bottom on vertical slider).
Slider:VALUE
Type: Scalar Get/Set

The current value of the slider.

Slider:ONCHANGE
Type: KOSDelegate Get/Set

This KOSDelegate takes one parmaeter, the value, and returns nothing.

This allows you to set a callback delegate to be called whenever the user has moved the slider to a new value. Note that as the user moves the slider to a new position, this will get called several times along the way, giving sevearl intermediate values on the way to the final value the user leaves the slider at.

Example:

set mySlider:ONCHANGE to whenMySliderChanges@.

function whenMySliderChanges {
parameter newValue.

print "Value is " +
round(100*(newValue-mySlider:min)/(mySlider:max-mySlider:min)) +
"percent of the way between min and max.".
}


This suffix is intended to be used with the callback technique of widget interaction.

Slider:MIN
Type: Scalar Get/Set

The “left” (for horizontal sliders) or “top” (for vertical sliders) endpoint value of the slider.

Note that despite the name, MIN doesn’t have to be smaller than MAX. If MIN is larger than MAX, then that causes the slider to swap their meaning, and reverse its direction. (i.e. where numbers normally get larger when you slide to the right, inverting MIN and MAX causes the numbers to get larger when you slide to the left.)

Slider:MAX
Type: Scalar Get/Set

The “right” (for horizontal sliders) or “bottom” (for vertical sliders) endpoint value of the slider.

Note that despite the name, MIN doesn’t have to be smaller than MAX. If MIN is larger than MAX, then that causes the slider to swapr their meaning, and reverse its direction. (i.e. where numbers normally get larger when you slide to the right, inverting MIN and MAX causes the numbers to get larger when you slide to the left.)