okSlider (Wire In)
ELEMENT | TYPE | DESCRIPTION |
---|---|---|
position | POSITION | Position of the top left corner. |
size | SIZE | Size in pixels. |
label | TEXT | Label text, shown inside the button. |
tooltip | TEXT | Tooltip text. |
endpoint | HEX BYTE | Endpoint address for the corresponding Wire In. |
bit | NUMBER | Bit to which this component addresses (0=LSB, 15=MSB). |
minvalue | NUMBER | The minimum value on the slider in base 10. |
maxvalue | NUMBER | The maximum value on the slider in base 10. This cannot exceed 255. |
value | NUMBER | Default value taken when the profile is loaded. |
style | STYLE | VERTICAL – Displays the slider vertically.HORIZONTAL – Displays the silder horizontally.SHOWLABELS – Show min/max/value labels. |
XML Example
<object class="okSlider">
<position>310,5</position>
<size>25,100</size>
<label>Hi</label>
<tooltip>4-bit vertical slider.</tooltip>
<style>VERTICAL|SHOWLABELS</style>
<minvalue>0</minvalue>
<maxvalue>15</maxvalue>
<value>3</value>
<endpoint>0x04</endpoint>
<bit>4</bit>
</object>
Code language: HTML, XML (xml)
Lua Scripting
This component supports executing a script function when its value changes. The current value can be obtained by using GetValue()
method and changed using SetValue()
, for example here is a function that could be used to maintain the sum of two sliders values constant:
Lua:
function OnSlider(slider, event)
local value = slider:GetValue();
local slider2 = okUI:FindPanel("panel1"):FindSlider("slider2")
slider2:SetValue(255 - value)
end
Code language: JavaScript (javascript)
Assuming the panel contains the following elements:
XML:
<object class="okSlider">
<position>15,15</position>
<size>200,30</size>
<style>HORIZONTAL</style>
<minvalue>0</minvalue>
<maxvalue>255</maxvalue>
<value>0</value>
<functionname>OnSlider</functionname>
</object>
<object class="okSlider" name="slider2">
<position>15,50</position>
<size>200,30</size>
<minvalue>0</minvalue>
<maxvalue>255</maxvalue>
<value>255</value>
</object>
Code language: HTML, XML (xml)
All XML components that support Lua scripting also inherit from the Control class. Please refer to the FrontPanel Scripting documentation for more information on this class.