Skip to content

Slider ​

A graphical horizontal slider for selecting a numeric value within a range, with an editable value box and low/high range labels.

Create with AceGUI:Create("Slider"). It inherits the Common Widget API.

Widget type: Slider

Methods ​

SetValue ​

method#
lua
widget:SetValue(value)

Sets the current value of the slider, moving the thumb and updating the value editbox. This sets the value directly and does not fire OnValueChanged.

Parameters

ParameterTypeDefaultDescription
valuenumberThe number to set as the current value (does not fire OnValueChanged).

GetValue ​

method#
lua
widget:GetValue()

Returns the slider's current value.

Returns

TypeDescription
numberThe slider's current value.

SetSliderValues ​

method#
lua
widget:SetSliderValues(min?, max?, step?)

Configures the slider's range and step increment, updates the low/high range labels, and re-applies the current value to the new range.

Parameters

ParameterTypeDefaultDescription
min (optional)number0Minimum value.
max (optional)number100Maximum value.
step (optional)number1Increment between selectable values. When > 0, values chosen by dragging are snapped to the nearest step.

SetLabel ​

method#
lua
widget:SetLabel(text?)

Sets the descriptive label shown above the slider.

Parameters

ParameterTypeDefaultDescription
text (optional)stringThe label text.

SetIsPercent ​

method#
lua
widget:SetIsPercent(value?)

Toggles percent display mode. When enabled, the value box and range labels are formatted as percentages (the stored value is multiplied by 100 for display and divided by 100 when typed).

Parameters

ParameterTypeDefaultDescription
value (optional)booleanTruthy to display as a percentage, nil/false for a plain number.

SetDisabled ​

method#
lua
widget:SetDisabled(disabled)

Enables or disables the slider. When disabled, the slider and value editbox stop accepting mouse input and are greyed out.

Parameters

ParameterTypeDefaultDescription
disabledbooleantrue to disable, false to enable.

Defaults ​

On acquire the slider resets to: width 200, height 44, not disabled, percent mode off, range 0–100 with step 1, value 0, and mouse wheel scrolling disabled (it is enabled once the frame is clicked).

Callbacks ​

OnValueChanged ​

callback#
lua
OnValueChanged(value)

Fired when the value changes via dragging or the mouse wheel (after step snapping), provided the new value differs from the current one and the widget is not disabled. Subscribe with widget:SetCallback.

Parameters

ParameterTypeDefaultDescription
valuenumberThe new value, after step snapping.

OnMouseUp ​

callback#
lua
OnMouseUp(value)

Fired when the user releases the mouse on the slider, and also when a value is committed by pressing Enter in the value editbox. Subscribe with widget:SetCallback.

Parameters

ParameterTypeDefaultDescription
valuenumberThe committed value.

OnEnter ​

callback#
lua
OnEnter()

Fired when the mouse enters the slider. Subscribe with widget:SetCallback.

OnLeave ​

callback#
lua
OnLeave()

Fired when the mouse leaves the slider. Subscribe with widget:SetCallback.

Example ​

lua
local slider = AceGUI:Create("Slider")
slider:SetLabel("Opacity")
slider:SetSliderValues(0, 1, 0.05)
slider:SetIsPercent(true)
slider:SetValue(0.75)
slider:SetCallback("OnValueChanged", function(widget, event, value)
    print("Opacity set to", value)
end)

Ace3, a World of Warcraft addon framework.