okTriggerMessage (Trigger Out)
okTriggerMessage displays a brief text message, similar to an okStaticText display, when a particular trigger occurs. Similar to okTriggerLog, you can setup a variety of messages to be displayed in the same area when any of a number of trigger outs occur.
ELEMENT | TYPE | DESCRIPTION |
---|---|---|
position | POSITION | Position of the top-left corner. |
size | SIZE | Size in pixels. |
style | STYLE | Acceptable border styles are: (none means no border) SIMPLE_BORDER RAISED_BORDER SUNKEN_BORDERAcceptable text styles are: ALIGN_LEFT (default) ALIGN_RIGHT ALIGN_CENTER |
trigger | XML | Adds a message to be displayed when a trigger event occurs. The XML contains ‘endpoint’, ‘bit’, ‘delay’, and ‘message’ tags as shown in the example below. The ‘delay’ parameter specifies an optional delay (in seconds), after which the message will disappear. |
XML Example
<object class="okTriggerMessage">
<position>5,290</position>
<size>200,20</size>
<style>RAISED_BORDER|ALIGN_CENTER</style>
<trigger>
<endpoint>0x60</endpoint><bit>1</bit>
<message>Your laundry is done.</message>
<delay>0.5</delay>
<background>#ff0000</background>
<foreground>#ffffff</foreground>
</trigger>
<trigger>
<endpoint>0x61</endpoint><bit>0</bit>
<message>Elvis (the cat) has left the building.</message>
</trigger>
</object>
Code language: HTML, XML (xml)
Lua Scripting
This component is similar to okTriggerLog
and doesn’t allow defining a script function, but can be used from the other script functions.
Once the object of this type is found using FindMessageLog()
method of the panel object, its AddMessage(message, delay, background, foreground)
method can be called. All the arguments except the first one are optional: by default, the delay is 0, meaning that the message will not be cleared automatically and the colors are not changed if they’re not specified.
Here is an example of using the component defined by the following XML fragment:
XML:
<object class="okTriggerMessage" name="message">
<position>15,50</position>
<size>200,20</size>
<style>RAISED_BORDER|ALIGN_CENTER</style>
</object>
Code language: HTML, XML (xml)
to show a message that will disappear after 5 seconds:
Lua:
local str = "Test message"
local background = OpalKellyUI.Color('#ff8888')
local foreground = OpalKellyUI.Color('#440000')
local triggerMessage = okUI:FindPanel("panel1"):FindMessageLog("message")
triggerMessage:AddMessage(str, 5, background, foreground)
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.