Build layout scripts
- Last UpdatedDec 06, 2024
- 3 minute read
The Layout Editor includes a tab for adding and editing scripts for execution at runtime. You can use different triggers, such as opening or closing the layout, to start the execution of a layout script, or setting an interval at which the script executes while the layout is open.
On Show layout scripts are executed before any graphic scripts contained within graphics in the layout, while On Hide layout scripts are executed after the graphic scripts. Other script types do not have a specific order of execution and may not execute in the same sequence each time. You can also add scripts triggered by events in an app or control, such as PropertyChange, MouseDown, etc.
Layout scripts work much like the graphic scripts that can be added to graphics to enable animation of the graphic or its elements. For more information about graphic scripts, see About Symbol Scripts.
The layout script editor includes the following features:
-
Autocomplete: as you type, the editor presents a dropdown list of namespaces, attributes, custom properties, exposed app properties, scripting methods, and other items that match the characters that you have entered. The items in dropdown list are filtered by context, so only valid items are listed in the dropdown.
Note: All public app properties will appear in the autocomplete list, even though not every public app property that appears in the list can be scripted. Properties that are not data-bound cannot be scripted. You can script public properties that contain their backing logic within the app itself. However, some apps which wrap around an underlying control, such as the Alarm App, contain pass-through properties which may require additional qualification. In a pass-through property, the backing logic is contained within the wrapped control. Therefore, to script a pass-through property, you must invoke the control namespace, even though autocomplete, by virtue of the property being public, will allow you to enter the property name with or without the control namespace. See Alarm client control pass-through properties for details.

The Layout Script Editor autocomplete feature works the same way as the Application Server QuickScript Editor and the Graphic Script Editor. For more information about Application Server scripting, see the Application Server Scripting Guide.
-
Event handler: add scripts that are triggered by user interaction with an app, such as a mouse click or a menu opening.
-
Search function: includes options to find, find next, or replace a specified string.
-
Undo/redo.
-
Script validation: flags invalid entries in the script.
The script editor contains three separate areas:
-
A pane at the left side of the editor lists all scripts within the layout. This list always includes the three built-in scripts (On Show, While Showing, and On Hide), and any named scripts and event-handler scripts that you add. Built-in scripts cannot be deleted or renamed, and are grayed-out until a script is added (regardless of the validity of the script). The number of lines in the script appears under the listed script name. If the script is not configured, the script shows that contains 0 lines. You can collapse and expand the script-list pane by selecting the chevron at the top right of the pane.
-
The top pane of the script editor contains an area to enter an expression and script trigger type. Other fields in the top pane are for timeout, period, deadband, and whether to include quality changes. These fields are enabled only if they are applicable to the selected trigger.
-
The main portion of the script editor has buttons for undo/redo, cut, duplicate, zoom in/out, and other editor functions. A button at the right of the pane lets you fully expand the editing pane. The cursor position is tracked by row and column numbers displayed at the bottom of the pane.