Slider

Package: Libraries.Interface.Controls · Inherits from: Libraries.Interface.Item, Libraries.Interface.Controls.Control, Libraries.Interface.Item2D, Libraries.Language.Object

A Slider chooses a number in a range by moving a thumb along a track. The track is filled in the accent color up to the thumb. When the slider has the focus, its thumb grows, turns the accent color and gets a soft halo. The user can change the value with the keys (Right and Up step up, Left and Down step down, Page Up and Page Down move a page step, Home and End go to the ends, and Shift with an arrow moves a tenth of a step), by dragging the thumb, by clicking the track to jump there, or with a screen reader. Listeners (AddSliderListener) are told of each change; while dragging the changes are not final, and one final change is sent when the drag ends. Its colors come from the interface options under the key "Slider": the background color is the track, the foreground the filled part, the accent the thumb, the border the thumb's edge, the focus border the focused thumb and its halo, and the focus color the focused thumb's edge.

Example Code

use Libraries.Interface.Forms.Form
use Libraries.Interface.Forms.Page
use Libraries.Interface.Controls.Slider

Form form
Page page = form:GetMainPage()

page:AddLabel("Brightness")
Slider brightness = page:AddSlider("Brightness", 0, 100)
brightness:SetValue(60)

form:Display()

Actions

AddSliderListener(Libraries.Interface.Events.SliderListener listener)

Adds a listener, told when the user changes the value.

Parameters

BeginPointer(number x)

This action is called when the mouse button goes down on the slider, at a place across the screen. Pressing the thumb grabs it where it is; pressing the track elsewhere jumps the thumb there. The slider takes the focus.

Parameters

  • x number: Where the pointer is, across the screen.

ChangeValue(number newValue, boolean isFinal)

Changes the value as the user does: kept within the range, the thumb moves, the screen reader is told, and so are listeners if the value changed.

Parameters

  • newValue number: The value.
  • isFinal boolean: False while a drag goes on, true otherwise.

EndPointer()

This action is called when the mouse button comes up: listeners are told of the change, once, as final, with the value before the button went down as the old value.

FineStepDown()

Moves the value a tenth of a step down, as Shift with Left or Down does.

FineStepUp()

Moves the value a tenth of a step up, as Shift with Right or Up does.

FormatNumber(number amount)

Writes a number with the slider's decimal places.

Parameters

  • amount number: The number.

Returns

text: The text.

GainedFocus(Libraries.Interface.Events.FocusEvent event)

This action is called when the slider gains the focus: its thumb grows and gets its halo.

Parameters

GetDecimalPlaces()

Returns how many decimal places the value is shown and said with. Unless set, it is worked out from the step: 2 for a step of 0.01.

Returns

integer: The decimal places.

GetMaximum()

Returns the greatest value.

Returns

number: The maximum.

GetMinimum()

Returns the least value.

Returns

number: The minimum.

GetNumberText()

Returns the value as a number with the slider's decimal places, such as "0.25" or "40".

Returns

text: The value as text.

GetPageStep()

Returns how much Page Up and Page Down change the value.

Returns

number: The page step.

GetStep()

Returns how much one key press changes the value.

Returns

number: The step.

GetUnits()

Returns the word said after the value, such as "degrees", or an empty text.

Returns

text: The units.

GetValue()

Returns the value.

Returns

number: The value.

GetValueText()

Returns what a screen reader says for the value: the number, then the units if there are any, such as "40 degrees".

Returns

text: The value text.

IsLogarithmic()

Returns true if the track is set to spread by ratios.

Returns

boolean: True if logarithmic.

IsPointerDown()

Returns true while the mouse button is down on the slider.

Returns

boolean: True while the pointer is down.

LoadGraphics(Libraries.Interface.Layouts.LayoutProperties properties)

Loads the parts' views the first time, then sets their colors, sizes and places.

Parameters

LostFocus(Libraries.Interface.Events.FocusEvent event)

This action is called when the slider loses the focus: its thumb goes back to its usual look.

Parameters

MovePointer(number x)

This action is called as the pointer is dragged: the thumb follows it, in steps.

Parameters

  • x number: Where the pointer is, across the screen.

MoveToMaximum()

Moves the value to the maximum, as End does.

MoveToMinimum()

Moves the value to the minimum, as Home does.

PageDown()

Moves the value a page step down, as Page Down does.

PageUp()

Moves the value a page step up, as Page Up does.

RemoveSliderListener(Libraries.Interface.Events.SliderListener listener)

Removes a listener.

Parameters

SetDecimalPlaces(integer places)

Sets how many decimal places the value is shown and said with, or -1 to work it out from the step.

Parameters

  • places integer: The decimal places.

SetLogarithmic(boolean value)

Sets whether the track is spread by ratios instead of differences, for a range whose useful values are spread unevenly, such as a size from 0.5 to 64: halfway along is the middle ratio (about 5.7), not the middle number (32). The step and page step are then factors greater than 1, such as 1.15 (each key press is 15% more) and 2 (Page Up doubles). It needs a minimum above 0; with a minimum of 0 or less the track is spread by differences as usual.

Parameters

  • value boolean: True to spread the track by ratios.

SetMaximum(number newMaximum)

Sets the greatest value. The value is kept within the range.

Parameters

  • newMaximum number: The maximum.

SetMinimum(number newMinimum)

Sets the least value. The value is kept within the range.

Parameters

  • newMinimum number: The minimum.

SetPageStep(number step)

Sets how much Page Up and Page Down change the value.

Parameters

  • step number: The page step, more than 0.

SetRange(number newMinimum, number newMaximum)

Sets the least and greatest values. The value is kept within the range. Listeners aren't told.

Parameters

  • newMinimum number: The minimum.
  • newMaximum number: The maximum.

SetStep(number step)

Sets how much one key press changes the value. Dragging and clicking the track also move in steps.

Parameters

  • step number: The step, more than 0.

SetUnits(text newUnits)

Sets a word said after the value by screen readers, such as "degrees", or an empty text for none.

Parameters

  • newUnits text: The units.

SetValue(number newValue)

Sets the value, kept within the range, as a program does: the thumb moves and the screen reader is told, but listeners aren't, since the user didn't change it. To change it as the user does, use ChangeValue.

Parameters

  • newValue number: The value.

StepDown()

Moves the value one step down, as Left or Down does.

StepUp()

Moves the value one step up, as Right or Up does.

Inherited Actions

261 actions from Libraries.Interface.Controls.Control
61 actions from Libraries.Interface.Item
202 actions from Libraries.Interface.Item2D
3 actions from Libraries.Language.Object