Form and Form Object Events
Form and form object events are similar to global events, but are defined for forms or individual form objects. These events can have an associated list of commands in a command sequence, or refer directly to a global, form, or local method.
Events Triggered by Data Change
For certain types of form objects, you can specify a method or command sequence to run when data is changed. This setting is available in the Events section of the Settings window of a form object, as shown in the figures below.
The drop-down list On data change contains None (the default), any available methods under the Methods node of the application tree or under the Methods node of the corresponding form, and a local method or command sequence (optional).
The form objects supporting this type of event are:
Buttons have associated events triggered by a click. Menu, ribbon, and toolbar items have associated events triggered by selecting them. The corresponding action is a command sequence defined in the Settings window of a button object or item. Note, however, that such command sequences can also be used to run methods. For more information on command sequences, see Button and Item.
Input Arguments
Clicking Create Global Method or Create Form Method will open a dialog where you can edit the name of the method to be created. Clicking Create Local Method will create a local method with an automatically created name indicating the form and type of event, see Local Methods. The method so created has a first argument called newValue which is based on the form object type. The argument added to the method will contain the new value in the form object when the event is triggered. The newly created method is also selected in the application tree and opened in the editor area.
For example, assume that you create a method based on an input field that links to a global parameter, as shown in the figure below.
The Settings window for the method created in this way is shown in the figure below.
The variable newValue will then contain the new value of the Mean velocity entered by the user of the app. In a similar way, if the method was created for an event associated with a checkbox, the variable newValue would be a Boolean variable indicating the new status of the checkbox.
This functionality makes it possible to write method code for processing input data and provides a general way of checking the input data in an app.
Selecting Multiple Form Objects
You can specify an On data change event for multiple form objects simultaneously by using Ctrl+click and then selecting the method or command sequence to run. In this way, you can, for example, quickly specify that a data change event initiated by any of the selected form objects should run a method that informs the user that plots and outputs are invalid. This functionality is not available for all combinations of form objects.
Events Triggered by Loading or Closing a Form
Forms can run methods or command sequences when they are loaded (On load) or closed (On close).
This type of event is available in the Settings window of a form and is typically used when a form is shown as a dialog, or to activate forms used as panes in a form collection. Note that, as described earlier, a method that is used for initializing graphics, such as Zoom Extents, needs to be run as an On load event for a form and not as a global On startup event.
Events Triggered by Focus
Certain form objects can have an On focus gained event, which is similar to an On data change event. This type of event is triggered when the user control associated with a form object comes into focus, for example, when clicking an input field. In general, a form object comes into focus when it becomes the target of keyboard input by the action of a mouse click or when cycling focus using the Tab-key.
The form objects supporting this type of event are: