Skip to content

form.addSliderField

since 1.5.2

Add a slider field to the current form.

form.addSliderField(line, rect, min, max, getValue, setValue)

Parameters

Name Type Required Description
line FormLine yes the line where the field should be added
rect Rect yes the coordinates
min integer yes the min value
max integer yes the max value
getValue function yes the function which will return the current value
setValue function yes the function which will be called on value change

Returns

The new field

Examples

From the official Ethos documentation
form.addSliderField(line, nil, 0, 100, function() return value end, function(newValue) value = newValue end)

Real-world usage

Called 6 times across 5 open-source Ethos Lua projects. A few short excerpts:
local posField = {x = graphPos['x_start'], y = graphPos['slider_y'], w = graphPos['width'] - 10, h = 40}
dashx.app.formFields[1] = form.addSliderField(nil, posField, 0, 100, function() return sliderPosition end, function(newValue) sliderPosition = newValue end)

src/dashx/app/modules/logs/logs_view.lua:470

local slider = form.addSliderField(nil, {x = graphPos.x, y = graphPos.sliderY, w = graphPos.w - 8, h = sliderH}, 1, 100, function()
  return sliderPosition
end, function(value)
  sliderPosition = value
end)

src/rfsuite/app/pages/logs.lua:540

state.fields.slider = form.addSliderField(nil, {
    x = layout.graphX,
    y = layout.sliderY,
    w = layout.sliderWidth,
    h = layout.buttonHeight
}, 1, 100,
function()
    return state.sliderPosition
end,
function(newValue)
    state.sliderPosition = newValue
end)

src/rfsuite/app/modules/logs/logs_view.lua:713