Skip to content

Slider : VisualElement

This is the slider class. It provides a draggable slider control that can be either horizontal or vertical, with customizable colors and value ranges.

Properties

PropertyTypeDefaultDescription
stepnumber1Current position of the slider handle (1 to width/height)
maxnumber100Maximum value for value conversion (maps slider position to this range)
horizontalbooleantrueWhether the slider is horizontal (false for vertical)
barColorcolorgrayColor of the slider track
sliderColorcolorblueColor of the slider handle

Events

EventParametersDescription
onChangevalue numberFired when the slider value changes

Functions

MethodReturnsDescription
Slider:getValuenumberGets the current value mapped to the max range

Protected Functions

MethodReturnsDescription
Slider:initSliderInitializes the Slider instance
Slider:mouse_clickbooleanUpdates slider position on mouse click
Slider:mouse_scrollbooleanHandles mouse release events
Slider:render-Renders the slider with track and handle

Slider:getValue()

Gets the current value of the slider

Returns

  • number value The current value (0 to max)

Usage

lua
local value = slider:getValue()
local value = slider:getValue()

Released under the MIT License.