Skip to content
Sharlikran edited this page Nov 28, 2020 · 4 revisions

The Slider control offers a powerful way to set numeric values. It shows a label followed by a slider with input field. The slider can be controlled by clicking and dragging or with the help of the mouse wheel. Values can also be entered via the input field below the slider.

A sample slider control

Data Table

property type default required description
type string - yes The widget type of this control ("slider")
name number, string, function - yes The label for the slider
getFunc function - yes The value provider for the checkbox. Needs to return a numeric value
setFunc function - yes The assignment function for the checkbox. Needs to accept a numeric value
min number - yes The minimum range for the slider
max number - yes The maximum range for the slider
step number 1 no The step size of the input. Input values will be forced to the closest acceptable value
clampInput boolean true no Wether or not the input field should accept values outside of the set range
clampFunction function - no function(value, min, max) return math.max(math.min(value, max), min) end, function that is called to clamp the value.
decimals number nil no When set to a positive integer, the input will be rounded to that many decimals
default number, function nil no Default value of the slider which is used to reset the panel to its defaults
warning number, string, function nil no Shows a warning icon beside the slider which has a tooltip with some warning text
tooltip number, string, function nil no The tooltip to display for the slider
requiresReload boolean false no Appends a special warning text and shows a reload button if the value is changed
disabled boolean, function false no Determines if the slider is disabled and its value cannot be changed
width string "full" no "full" or "half" width in the panel
reference string nil no A unique global reference to the control
readOnly boolean - no When true, you can use the slider, but you can't insert a value manually
helpUrl string, function - no A string URL "https://www.esoui.com", or a function that returns one
autoSelect* boolean false no When set to true, everything in the input field will be selected when it gains focus
inputLocation* string "below" no "below" or "right". Determines where the input field is shown.

*This should not be used within the addon menu to ensure a consistent user experience and is for custom sliders outside of the addon menu only.

Exposed Methods

control:UpdateValue([boolean forceDefault[, number value]])

This method updates the state of the slider with the value returned by getFunc if no arguments are passed. If forceDefaults is true, it will set the slider to the value in the default property. If forceDefaults is false and value is not nil, it will set the slider to the passed value

control:UpdateDisabled()

Only is exposed when the disabled property is not nil. This method updates the disabled state of the slider based on the resolved value of the disabled property.

control:UpdateWarning()

Only is exposed when the warning property or the requiresReload property is set. This method updates the warning of the slider based on the resolved value of the warning and requiresReload property.

Examples

LAM:RegisterOptionControls(panelName, {
	{
		type = "slider",
		name = "My Slider",
		getFunc = function() return saveData.myNumber end,
		setFunc = function(value) saveData.myNumber = value end,
		min = 0,
		max = 100,
		default = defaultData.myNumber,
		reference = "MyAddonSlider"
	}
})
local controls = {}
controls[#controls + 1] = {
	type = "slider",
	name = "My Other Slider",
	getFunc = function() return saveData.myOtherNumber end,
	setFunc = function(value) saveData.myOtherNumber = value end,
	min = 0,
	max = 1,
	step = 0.01,
	decimals = 2,
	width = "half"
}
LAM:RegisterOptionControls(panelName, controls)