User Interface Scripting

Manifold supports scripting of user interface elements such as dialogs and controls. User interface scripting is available for regular scripts and forms, but is unavailable for active columns, where it would be impractical for performance reasons, external applications and web sites using Manifold objects (where there is no Manifold user interface present).


Scripting of the user interface allows running interactive commands and controlling dialogs and controls, with scripting supported for common Windows controls such as buttons, check boxes, labels, text boxes, list boxes, combo boxes, tree views and list views. User interface scripting objects support scripting of the progress bar and slider controls, via the Text property. All Manifold dialogs support user interface scripting.


Scripts that operate with user interface elements must be run in a thread separate from the user interface thread. This can be arranged via the Properties context menu that pops up when we right click on a script in the project pane and choose Properties. This menu allows us to check the Run in separate thread property. Running a script in a separate thread allows using advanced scripting techniques such as scripting the user interface, but might be slightly slower in some cases. By default, the option is turned off so this property must be explicitly set to enable user interface scripting.


Form scripts can be configured to run in a separate thread, which allows scripting the user interface. Running a script from another script spawns a new thread, in case the callee is configured to run in a separate thread. This allows freely mixing scripts that are configured to run in the calling thread or a new thread.


User interface scripting objects support numerous Manifold facilities, including:


·      Scripting panes in the main window as well as scripting toolbar controls. Each toolbar button is interpreted as a separate user interface control.

·      Scripting combo boxes, text boxes and other non-button controls in toolbars.

·      Support for "pushing" buttons in the drop-down portions of color, size, and style wells, such as buttons for invoking the thematic formatting dialog, and similar windows.

·      Support for scripting format lists such as the list of colors in the Display Options dialog for surfaces.

·      Invoking a user interface command within a script allows specifying the command context to access commands available in the various context menus and in panes.

·      User interface scripting objects support reading and writing values of items in list view controls, such as the list view in the contouring dialog.


User interface scripting objects also support scripting non-Manifold dialogs, such as the open file dialog. Names of controls for non-Manifold dialogs are synthesized on the fly.


Example - Spatial Overlays


Suppose we have a map component called Map that includes a drawing of areas named States and a drawing of points named Cities. The drawings share some common columns. We can script a spatial overlay with the following:


Sub Main


Set ui = Application.UserInterface

ui.InvokeCommand "MapSpatialOverlay"

Set dlg = ui.ModalDialog

dlg.ControlSet("ComboBoxSource").Text = "[All Objects in States]"

dlg.ControlSet("ComboBoxTarget").Text = "[All Objects in Cities]"

dlg.ControlSet("ComboBoxMethod").Text = "Areas to contained points"


End Sub


Discovering Control Names


It's easy to discover the names assigned to various controls in Manifold dialogs. Right clicking the caption of a dialog or undocked pane or toolbar and choosing List Controls from the context menu will display a list of programmatic names of dialog or pane controls or toolbar commands that may be used with user interface scripting.


Another choice is to use the /clist command line option, which dumps the names of all commands available for user interface scripting using the InvokeCommand method of the UserInterface object into a text file.


Example - Discover Control Names in the Dissolve Dialog


If we open a drawing and then choose Drawing - Dissolve we open the Dissolve dialog.




Right clicking on the caption for the dialog...




...and then choosing List Controls from the context menu...




...will display the Controls list of the names of controls available for programmatic use.


Tech Tip


Attempting to locate a pane using its name within a script allows omitting the component name postfix. For example, attempting to locate a pane named Control Points will succeed even if there is an active component, which sets the pane name to Control Points - [Component Name].


See Also