Skip to end of metadata
Go to start of metadata

This is a sub-class of Widget

The functions and fields of the widget class are also available for the slider class. For instance you can assign an actionListener to the slider which will be called when the value changes.

Constructor

mgf.createSlider( min, max )

ParameterTypeDescription
minimumNumberThe minimum value of the slider.
maximumNumberThe maximum value of the slider.
Contructor example
slider = mgf.createSlider(0,100)

Fields

FieldTypeDescriptionRead/Write
valueNumberThe current value of the slider.Read/Write

Functions

Slider does not support any additional functions.

Actions

ActionValueDescription
Slider changed0Called when a user changes the value of the slider.

Examples

Example: Slider action listener
-- Execute this function when the slider changed value
function sliderListenerFunction( widget )
    print( "Slider value changed" )
    
    -- Adjust the label value
    valueLabel.label =  "Value: " .. widget.value
end
 
-- Create a slider with an initial value of 30
local slider = mgf.createSlider(0,100)
slider.value = 30
 
-- Create a label
-- Note: this can't be local, we want to access this from the sliderListenerFunction()
valueLabel = mgf.createLabel( "Value: " .. slider.value )   
 
-- Create a panel and add the widgets
local panel = mgf.createPanel()
panel:addWidget( valueLabel,50,100,150,50 )
panel:addWidget( slider,25,150,200,25 )
mgf.setWidget( panel )
 
-- Set the action listeners of the function that will be called when changing the slider value
slider.actionListener = sliderListenerFunction

 

 

  • No labels