The Event node (

) adds an event that listens to a change in the runtime model. If a change occurs, it runs an action. It can listen to data field changes, the creation of features, and the removal of features. Enter the name of the Event object in the
Name field.
The Settings window contains the following sections:
This section contains a tree with a filtered view of the trees in the Application Builder and
Model Builder windows. The nodes either represent some sort of data or have children that do. For an event, variable declarations under
Declarations are available as sources. In addition, under
Model, global parameters, variables under
Definitions in a component, and explicit selection nodes are available as sources. With an explicit selection as the source, you can have some method that runs whenever that explicit selection changes (the change can be triggered by code in some method or from user interaction with a selection input or a graphics object form object). For example, the application can run a method when the user clicks boundaries in the graphics.
When you select a node that represents data, the Use as Source toolbar button below the tree becomes enabled. You can also right-click the node and choose
Use as Source. You can also click the
Create button (

) in the
Source for Data Change Event section header to create a new variable declaration for the form object and use it as the source. A
Create and Use Variable dialog box opens, so that you can select the data type of the source (if applicable) and its name. The name cannot be in conflict with any existing variable declaration. Click the
Edit Node toolbar button (

) below the tree to move to the corresponding node.
Typically, you only see the available parameters under the Parameters node, variables under a
Variables node, and the data nodes defined under the
Declarations branch in Application Builder part of the Application tree (underneath the
Events branch). You can extend the list of available data nodes by clicking the
Switch to Model Builder and Activate Switch to Model Builder and Activate Model Data Access button (

) in the
Source for Data Change section header, which takes you automatically to the Model Builder. Then select a node in the
Model Builder branch with data you want to access. With this button active, the
Settings window of the selected node displays a
Select Data Source check box (a green square) next to the settings that you can include. Select the check box to include that data as an available source node for events.
Any restrictions on a data source are passed along to the user interface of the application. For example, a Load type list in a
Boundary Load node for structural mechanics only allows three values. Any form object using this data as its source can only support a subset of those values.
In this section you choose the commands to run for the event. The section contains a tree with a filtered view of the trees in the Application Builder and
Model Builder windows. The nodes either support a command or have children that do. When you select a node that supports one or more commands, the corresponding command toolbar buttons become enabled in the toolbar below the tree. You can also right-click a node to get a list of available commands for that particular node. Once you click on a command with a node selected, the command and node appear in the last row of the table below the tree. This table contains all nodes that run, and you can delete and move commands using the toolbar below the table.
In the Model branch, all nodes that represent some sort of data value, such as a parameter under the
Parameters node, support the
Set Value command. When adding a
Set Value command to the table, the third column,
Arguments, becomes enabled. In this column you type the value to set. For data that represents arrays, use curly braces and commas to enter the array elements. For example, enter
{1,2,3} to set a three-element array with the values 1, 2, and 3. See the
The Array 1D String Node for more details on how to enter arrays and matrices. For nodes that represent a file import, such as a
Filename node under an
Interpolation function node, an
Import File command is available.
•
|
The Forms branch: Form nodes support the commands Show, which sets the form as the main form of the application (that is, the content of the application window will be this form), and Show as Dialog, which brings up the form as a separate dialog window.
|
•
|
The GUI Commands branch: The commands under this branch are grouped in three subcategories:
|
-
|
File Commands: These include Save Application (to save the application under its current name); Save Application As (to open a file browser dialog allowing the user to save the application in a suitable location); Save Application on Server; Save Application on Server As; Open File (to open an application file resource specified using a valid URI path in the Arguments column); Save File As (similarly, to allow the user to save the file under a name specified in the Arguments column); and Exit Application (to close the running application). If the application is run on COMSOL Server, the Save Application on Server and Save Application on Server As commands save the current state as a new application in the COMSOL Server Application Library.
|
-
|
Graphics Commands: Here you find the commands Zoom Extents, Reset Current View, Scene Light, Transparency, and Print. For all graphics commands, add the name of the Graphics object that you want to apply the command to as an argument.
|
-
|
Model Commands: Here you find the commands Clear All Solutions and Clear All Meshes.
|
•
|
The Declarations branch: This branch contains any variable declarations you have added under the Application Builder window’s Declarations branch grouped by type. Like parameters, they support the Set Value command.
|
•
|
The Methods branch: Method nodes support the Run command.
|
•
|
The Libraries branch: Under Sounds, you can choose between sound files to play in a command sequence.
|
When you click one of the commands underneath the tree, the command appears under Command in the list below. There is also a
Symbol column and an
Arguments column, where you can enter any applicable arguments that the command uses. A tooltip appears, indicating what type of argument that the command expects. For example, for the
downloadtoclient command, the argument is both a filename and its path, such as
embedded:///myfile.txt, and there is a separate dialog box that helps you define such an argument. See
File Schemes and File Handling for more information.
Click the Create Local Method button (

) underneath the list of commands to convert the entire list of commands in the table to a new local method that contains the equivalent code and to open an editor window for that local
onEvent method. When you have not created a local method, click the
Convert to New Method toolbar button (

) to convert the entire list of commands in the table to a new
Method node that contains the equivalent code. After this operation, the list of commands only contains a single
Run operation on the created
Method node. When you select a method under
Command, or if there is exactly one method in the list, you can go to the editor window for that method by clicking the
Go to Method button (

). For information about the
Edit Argument button (

), see
Editing Initial Values and Arguments in Declarations and Command Sequences. Use the
Move Up (

),
Move Down (

), and
Delete (

) toolbar buttons to organize and remove commands from the list (and also remove the local method, if deleted).
You can extend the list of available nodes by clicking the Switch to Model Builder and Activate Model Data Access button (

) in the
Choose Commands to Run section header, which takes you automatically to the Model Builder, and then selecting a node in the
Model Builder branch that you want to access. With this button active, the
Settings window of the selected node displays a
Select Data Source check box (a green square) next to the settings that you can include. Select the check box to include that data as an available source node for events.