A slider item is used to place a slider on the rollout, as an alternative to a spinner. The user can drag the slider's pointer around to set its value. The syntax is:
slider <name> [ <caption> ] [ range:[min,max,val] ] \
[ type:#float ] [ ticks:10 ] \
[ orient:#horizontal ]
The default alignment of slider items is #center.
Example:
slider tilt "Head tilt" orient:#vertical ticks:0 range:[-30,30,0]
on tilt changed val do $head.bend.angle = val
Parameters
range:
A Point3 value containing the minimum, maximum and initial values for the slider in the x, y, and z components, respectively. Defaults to [0,100,0].
type:
The type of the slider, #float or #integer. Defaults to #float.
orient:
The layout orientation of the slider in the rollout, either #vertical or #horizontal. Defaults to #horizontal.
ticks:
Specifies how many ticks to place along the slider bar. No ticks are drawn if you specify ticks:0. Defaults to 10.
Properties
<slider>.range Point3
The current range and value for the slider, as a Point3 like the range: parameter.
<slider>.value Float
The current value of the slider.
<slider>.ticks Integer
The number of ticks along the slider.
Events
on <slider> changed <arg> do <expr>
Called when the user moves the slider pointer. The <arg> argument contains the new value of the slider.
on <slider> buttondown do <expr>
Called when the user first clicks the slider.
on <slider> buttonup do <expr>
Called when the user releases the slider.
The buttonDown and buttonUp events effectively notify you of the start and end of a slider "twiddle", allowing you to perform some setup for the adjustment. A typical use for this is to bring scene nodes that are being modified in the on <slider> changed handler into the foreground plane to speed up screen redraw. For example:
spinner foo "height: "
on foo buttonDown do flagForeground $baz...* true
on foo buttonUp do flagForeground $baz...* false
Note: If you are using a slider to interactive adjust a property of an on-screen object, you can improve the interactive speed by moving the object to the foreground plane. Objects placed in the foreground plane are redrawn individually and so interactive changes to them are much faster. An object is moved to the foreground or background plane using the flagForeground() method:
flagForeground <node> <boolean> -- mapped
The boolean argument puts the scene node(s) into the foreground plane if true, or into the background plane if false.
You should be judicious in putting objects in the foreground plane, because putting too many objects in the foreground plane reduces the foreground plane's effectiveness. Remember to return objects to the background plane when you don't need to interactively control them any more.
See also
Rollout User-Interface Items Common Properties