Slider

This function creates a slider widget. A slider allows the user to drag a knob to adjust a setting within a fixed range of allowed values.

Syntax

Parameters

Returns

Returns a new slider.

Example

local window = Window:Create()
local context = Context:Create(window)
local gui = GUI:Create(context)
local base = gui:GetBase()
base:SetScript("Scripts/GUI/Panel.lua")

x=20
y=20
local sep=30

widget = Widget:Slider(x,y,300,20,base)
y=y+sep

widget = Widget:Slider(x,y,300,20,base)
widget:SetStyle(SLIDER_TRACKBAR)
y=y+sep

widget = Widget:Slider(x,y,40,20,base)
widget:SetStyle(SLIDER_STEPPER)
y=y+sep*1.5

widget = Widget:Slider(x,y,20,150,base)
widget:SetStyle(SLIDER_VERTICAL)
x=x+sep

widget = Widget:Slider(x,y,20,150,base)
widget:SetStyle(SLIDER_VERTICAL + SLIDER_TRACKBAR)
x=x+sep

widget = Widget:Slider(x,y,20,40,base)
widget:SetStyle(SLIDER_VERTICAL + SLIDER_STEPPER)
x=x+sep

while true do
if window:Closed() then return end
if window:KeyHit(Key.Escape) then return end

while EventQueue:Peek() do
local event = EventQueue:Wait()
if event.id == Event.WidgetAction then
System:Print("WidgetAction")
elseif event.id == Event.WidgetSelect then
System:Print("WidgetSelect")
end
end

context:Sync()
end