okToggleButton (Wire In)
The okToggleButton is similar to the okPushbutton in that it connects to a Wire In endpoint. In contrast to the okPushbutton, however, this component maintains its state just as a physical toggle switch would. When unpressed, the corresponding wire is deasserted (logic 0). When pressed, the corresponding wire is asserted (logic 1).
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). |
XML Example
<object class="okToggleButton">
<label>RA</label>
<position>10,10</position>
<size>20,20</size>
<endpoint>0x00</endpoint>
<bit>0</bit>
</object>
Code language: HTML, XML (xml)
Lua Scripting
This component is similar to okPushbutton and supports executing a script function when its pressed or released. The button
object passed to the script function provides a GetValue()
method which can be used to determine whether the button is currently pressed or released, e.g. an example function could be written like this:
Lua:
function OnToggleEvent(button, event)
if button:GetValue() then
button:SetLabel("On")
else
button:SetLabel("Off")
end
end
Code language: JavaScript (javascript)
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.