Slider Widget
The slider widget is used for scrollbars, trackbars, and steppers. It has a lot of style options, so it's really six different widgets packed into one. (In Leadwerks Editor, a slider and textfield widget are combined to make the numerical entries you use to adjust positions and other values.)
To create a new slider you just create a widget and set the slider script:
local slider = Widget:Create(230+40,140,20,20,panel) slider:SetScript("Scripts/GUI/Slider.lua")
You can then set the style. The style should be set after the script is assigned. This is because the style flags are initialized in the slider script, so if it hasn't been run already those values will be nil:
slider:SetStyle(Style.Slider.Stepper + Style.Slider.Horizontal)
The slider can be any of these styles:
- Style.Slider.Scrollbar
- Style.Slider.Trackbar
- Style.Slider.Stepper
And can be combined with the following to be either horizontal or vertical:
- Style.Slider.Horizontal
- Style.Slider.Vertical
The default appearance is a vertical scrollbar.
When a slider is moved either by clicking and dragging it with the mouse, clicking on the trackbar, moving the mouse wheel when the widget is focused or pressing the arrow keys when the widget is focused, the widget will emit a WidgetAction event, with the slider value stored in the event.data member.
So far none of the widgets are using any images. The arrows and slider knob are using DrawPolygon() to render the shape.
This is available now on the beta branch on Steam, for Lua on Windows only at this time.
- 8
4 Comments
Recommended Comments