Jump to content
  • entries
    941
  • comments
    5,894
  • views
    868,001

Slider Widget


Josh

2,327 views

 Share

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.)

 

blogentry-1-0-80508400-1469725083_thumb.png

 

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.

  • Upvote 8
 Share

4 Comments


Recommended Comments

Is there a way to set the initial position of the slider knob? eg volume is set at say 50 at program start.

Link to comment
Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...