The Edit Custom Toolbar Item Dialog Box
There are several ways to add a custom button or toggle button to a toolbar object, for a table, or for a graphics object. To create a button item or toggle button item and open the Edit Custom Toolbar Item dialog box to define it, use one of the steps below. The Edit Custom Toolbar Item dialog box provides settings and tools for creating a custom button or toggle button with an associated command or method to run.
For a Toolbar object, click the Add Item () or Add Toggle button () underneath the table of items in the Toolbar Item section, or right-click the toolbar in the Form window and choose Add Item () or Add Toggle button (). You can also open it by right-clicking a custom toolbar button or toggle button in the Toolbar object’s Settings window and choosing Edit.
For a Table object, click the Add Toolbar Item button () in the Toolbar section of the Settings window. Then, in the Toolbar Items dialog box, click the Custom Item button or the Custom Toggle Item button to open the Edit Custom Toolbar Item dialog box. You can also open it by right-clicking a custom toolbar button or toggle button in the Table object’s Settings window and choosing Edit.
For a Graphics object, click the Add Item () or Add Toggle button ( at the bottom of the Toolbar section in the Settings window. You can also open it by right-clicking a custom toolbar button or toggle button in the Graphics object’s Settings window and choosing Edit.
The Edit Custom Toolbar Item dialog box includes the following pages:
General
In the Name field, type the name of the toolbar button that you use to refer to it.
In the Text field, type the text that appears as a label on the button.
From the Icon list, choose None for no icon or choose an icon from existing image files. Click the Add Image to Library and Use Here button () to browse and select an image to use as the icon. Click the Export button () to save the icon as an image file. If you use an icon and a text label, the toolbar item includes both the icon and the label.
From the Selected icon list, choose an icon that will be used to represent the selected state of the toggle item, from the Icon list, which includes all images in the Images library, or click the Add Image to Library and Use Here button () to locate an image to use on the file system. That image then becomes a part of the Images library and selected as the icon to use on the toggle item. To display only the text, select None from the Icon list. Click the Export button () to export the image to the file system (for use in another application, for example). The Default setting uses the same icon for both the selected and the deselected states.
In the Tooltip field, enter an explanatory text that will appear as the tooltip for the button or toggle button. In the Toolbar Items dialog box, the added button appears with its tooltip, if the text label is empty.
To add a keyboard shortcut, make the Keyboard shortcut field active, and then type a keyboard shortcut on the keyboard:
You must use a modifier in the keyboard shortcut, not just a plain letter (for example, CTRL+SHIFT+D). The shortcut can include the Ctrl key (CTRL), Alt key (ALT), and Shift key (SHIFT). Note that the Ctrl key is interpreted as Command on OS X. Avoid using the following keys in your shortcut:
Source
The Source page is only available for toolbar toggle buttons.
Here you specify the source for the state of a toggle button in a toolbar. The source can be string or Boolean variable that is created under Declarations, which you select from the tree and then click the Use as Source button (). Alternatively, press Enter, double-click, or right-click the node and choose Use as Source to add it as the selected source. You can also click the Create New Declaration and Use It as Source button () or the Create New Form Declaration and Use It as Source button () below the source list to create a new global or local (in the form) variable declaration for the toolbar item and use it as the source. A Create and Use Declaration dialog box opens so that you can select the data type of the source (if applicable), its name, and its initial value (if applicable). The name cannot be in conflict with any existing variable declaration. When you have specified a source, use these settings to define its initial state:
From the Initial value list, choose From data source (the default) to use the initial value from the data source, or choose Custom value to define an initial state using the Initial state list: Choose Selected (the default) or Cleared (the value for selected is on; for cleared, it is off).
Choose Commands to Run
This section contains a tree with a filtered view of the tree in the Application Builder window. 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 are 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 a command with a node selected (or press Enter or double-click to add a command with its default command such as Run, Plot, or Set Value), 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 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 tree includes a number of branches from the application tree in addition to the Model branch:
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, Zoom to Selection, Reset Current View, Scene Light, Environment Reflections, Show Skybox, Rotate Environment, Transparency, Print, Select All, Clear Selection, Show Selection Colors, and Show Material Color and Texture. 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.
Double-click or right-click any of the nodes above to add a Run command.
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 Form Declarations branch: This branch contains any variable declarations you have added under a Declarations branch under the current Form node. Like parameters, they support the Set Value command.
The Methods branch: Method nodes support the Run command.
The Form Methods branch: Method nodes under the current Form node 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 buttons underneath the tree, the currently selected command appears in the Command column in the table below. There are also Icon and Arguments columns, where you can enter any applicable arguments that the command uses.
Click the Convert to Method toolbar button () and choose Convert to Method or Convert to Form Method to convert the entire list of commands in the table to a global or form method that contains the equivalent code. After this operation, the list of commands only contains a single Run operation on the created method. When you select a method under Command, or 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 to remove the local method, if deleted).
Click OK to close the Edit Custom Toolbar Item dialog box and add the button to the toolbar.