Navigation: Interface Design Concepts > Event Code >

Triggered Event Code

 

 

 

 

Interfaces and Controls are triggered to Event Code. While most of these triggers are obvious, such as clicking a button or changing text in a textbox, there are other events that can cause the event code to run, and code may be written specifically for those triggers.

Writing Triggered Event Code

Writing triggered event code is done by enclosing the trigger name in < > and writing the specific code after it on the same line. Such as code to run when the Main Interface is clicked:

<click>!bell

Or double-clicked:
<dblClick> ? I was double-clicked!

Most controls respond and run their code with no trigger events being used or declared, such as moving a pressing a command button:
!plot.reset

The Canvas Control and the Interfaces require the use of Triggered Event Code:

<click>                    Interface is clicked, will also trigger a <release> event.
<dblClick>          Interface is double-clicked, will also trigger a <click> and <release> event.
<release>          Mouse is released
<drag>                    Mouse is dragged on the Interface
                    The above triggers return of the X and Y positions of the mouse pointer as [mouseX] and [mouseY],
                    or [name.mouseX] and [name.mouseY] for Child Interfaces and Canvas Controls.
<analog>          Triggered when analog data is received.
<digital>          Triggered when digital data is received.
<message>          Triggered when message data is received.

The Analog Plot requires the use of Triggered Event Code:

<click>                    Interface is clicked, will also trigger a <release> event.
<dblClick>          Interface is double-clicked, will also trigger a <click> and <release> event.
<analog>          Triggered when analog data is received.
 

The Digital Plot requires the use of Triggered Event Code:

<click>                    Interface is clicked, will also trigger a <release> event.
<dblClick>          Interface is double-clicked, will also trigger a <click> and <release> event.
<digital>          Triggered when digital data is received.

Many controls will respond to events without events, but may use Triggered Events. For example, a checkbox and toggle buttons when clicked will run the event code regardless, but may also use their Triggered Events:

<on>                    The control was turned on
<off>                    The control was turned off

Similarly with meters, if alarming is enabled and the high or low setpoints are exceeded, the corresponding events may be used to decide which was triggered:
<high>                    The meter value exceeded the max setpoint
<low>                    The meter value exceeded the min setpoint (went below it)

When event code has both triggered and non-triggered event code, if the specified trigger is declared, only that code will run, such as for a checkbox being turned - turn on will trigger <on>, but turning <off> will not trigger <on> so any default code will run - default code must follow events:

<on> ? [this] was turned on
? [this] was turned off

When you need multiple instructions to be ran for a Triggered Event, either use semi-colons to separate instructions or declare the trigger on each line:

<on> ? [this] was turned on; !bell
<on> ? [this] was turned on
<on> !bell

Viewing Available Events for a Control

There are several ways to view possible events for a control or Interface:

View their references in this document

Open the Code Editor for the control or interface (double-click the Event Code textbox in the Interface Editor) and type <

After controls are placed, use the Controls Viewer to view the events of a control (F6):

 

The Load Event

All Controls and Interfaces have a load event trigger. The code for load will run when a !runLoad instruction is issued. This is automatically placed in the Interface File when saved. This allows actions to take place for that specific control when they are created from the Interface File or when !runLoad is issued.

A use for this may be to create a variable needed for the control's event code and to initialize it to some value:
<load>!makeVar varAveragePower; varAveragePower = 0

Please see Variables for more information on using them as there are some intricacies in using variables.

 

Making New Events Triggers

All Event Code allows the use of user-defined triggers, such as in the a Child Interfaces Event Code:

Create a new child Interface while in Edit Mode (F9) called intFoo, set the event code to the following and exit Edit Mode.

<test> ? Test complete!
? No trigger

Test the Child's code with the following from the Debug/CLI Window:
!intFoo.run
!intFoo <test>

In the first, the non-triggered code is ran, only the triggered for <test> is ran.

Passing Data to an Event

Data may be passed when running event code.

Please see Passing Data to Events for more information.

 

 


 

 

 

 

Copyright © 2024 SelmaWare Solutions, LLC