okPushbutton (Wire In)
This component models a physical pushbutton and connects to a Wire In endpoint. By default, the pushbutton is ‘unpressed’ and the corresponding wire is deasserted (logic 0). When pressed, the corresponding wire is asserted (logic 1). The pushbutton does not hold its state — that is, to maintain a logic 1, you have to hold the pushbutton in its pressed state.
For an alternative component that does maintain its state, see the okToggleButton.
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="okPushbutton">
<label>Disable</label>
<position>90,25</position>
<size>60,20</size>
<endpoint>0x00</endpoint>
<bit>1</bit>
<tooltip>Momentarily disable counter #1</tooltip>
</object>
Code language: HTML, XML (xml)
Lua Scripting
This component supports executing a script function when the button is pressed or released. The function can distinguish between the two kinds of event by calling button:IsPressed()
on the button
object passed to it as the first argument.
If the button has an associated script function, it may avoid specifying the endpoint
and bit
parameters that are normally required. However it can also use both the function and these parameters, in which case the default button action, of asserting or deasserting the corresponding wire when it’s pressed or released, will be taken after executing the script function unless it explicitly calls event:PreventDefault()
as described in the “Default Behaviour” section.
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.