SliderField

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

A SliderField is a label, a Slider and a small number field, kept in step. They share one line when there is room; in a narrow container the label and field share a line and the slider goes under them (SliderFieldLayout). The slider gives quick changes and the field gives exact ones: moving the slider writes its value in the field, and a number typed in the field moves the slider when the focus leaves the field. Each is its own focus stop with the same name, so a screen reader user can use either. Listeners added with AddSliderListener are told of changes from both: a typed number is sent as a final change. It can stand in for a number field: a number a program puts in its field (GetField():SetText) moves the slider too, unless the field has the focus (someone is typing), and moving the slider writes the number in the field, so the field's own text change listeners hear it.

Example Code

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

Form form
Page page = form:GetMainPage()

page:AddLabel("Volume")
SliderField volume = page:AddSliderField("Volume", 0, 100)
volume:SetValue(75)

form:Display()

Actions

AddSliderListener(Libraries.Interface.Events.SliderListener listener)

Adds a listener, told when the user changes the value with either part.

Parameters

AllowsValuesBeyondRange()

Returns true if numbers outside the slider's range are kept (SetAllowsValuesBeyondRange).

Returns

boolean: True if they are kept.

FieldTextChanged()

Called when the field's text changes: a number a program put there moves the slider (without telling listeners). While the field has the focus, someone is typing, and the number is taken when the focus leaves instead.

GetField()

Returns the number field.

Returns

Libraries.Interface.Controls.TextField: The field.

GetLabel()

Returns the label at the left.

Returns

Libraries.Game.Graphics.Label: The label.

GetSlider()

Returns the slider.

Returns

Libraries.Interface.Controls.Slider: The slider.

GetValue()

Returns the value.

Returns

number: The value.

RemoveSliderListener(Libraries.Interface.Events.SliderListener listener)

Removes a listener.

Parameters

SetAllowsValuesBeyondRange(boolean allow)

Sets whether a number outside the slider's range may be typed in the field, or set by a program, and kept. The field keeps the number and GetValue returns it, while the slider rests at its nearest end; moving the slider again gives its own value. Off, the default, such a number is brought into the range. A setting with a usual range but no real limit, such as an item's scale, can use it.

Parameters

  • allow boolean: True to keep numbers beyond the range.

SetDecimalPlaces(integer places)

Sets how many decimal places the value is shown with, or -1 to work it out from the step (Slider:SetDecimalPlaces).

Parameters

  • places integer: The decimal places.

SetLabelText(text value)

Sets the words shown at the left, such as "Lean:", in a column so the labels of several slider fields line up. Empty for none.

Parameters

  • value text: The label's words.

SetLabelWidth(number width)

Sets how wide the label's column is, in pixels before the interface scale. The default is 120.

Parameters

  • width number: The column's width.

SetLogarithmic(boolean value)

Sets whether the slider's track is spread by ratios, for a range whose useful values are spread unevenly (Slider:SetLogarithmic). The step and page step are then factors, such as 1.15 and 2.

Parameters

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

SetUnits(text units)

Sets a word said after the value by screen readers, such as "degrees".

Parameters

  • units text: The units.

SetValue(number value)

Sets the value, as a program does: the slider moves and the field shows it, but listeners aren't told.

Parameters

  • value number: The value.

Setup(text name, text description, number minimum, number maximum, number step, number pageStep)

Sets the name both parts are known by, their description, the range, the step for a key press and the page step.

Parameters

  • name text: The name, such as "Lean".
  • description text: What the value does.
  • minimum number: The least value.
  • maximum number: The greatest value.
  • step number: How much one key press changes the value.
  • pageStep number: How much Page Up and Page Down change it.

SliderChanged(Libraries.Interface.Events.SliderChangedEvent event)

Called by the slider when the user changes it: the field shows the new value.

Parameters

TakeFieldText()

Called when the focus leaves the field: a number typed in it moves the slider, kept within the range, and listeners are told as for a final change. Anything that isn't a number is put back.

Inherited Actions

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