Working With Forms > The Form Objects > The Edit Custom Toolbar Button Dialog Box

The Edit Custom Toolbar Button Dialog Box
From the Toolbar Buttons dialog box for adding toolbar buttons to a Table, click Custom Button to open the Edit Custom Toolbar Button dialog box. You can also open it by right-clicking a custom toolbar button in the Table node’s Settings window and choosing Edit. It provides the following settings and tools for creating a custom button with an associated command or method to run:
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 button tooltip, if you use an icon, or as a label on the button if there is no icon.
From the Icon list, choose None to use 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.
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 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 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, 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.
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 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 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 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 onClick method. You can also Ctrl+Alt-click on the button object or right-click it to create a local method. When you have not created a local method, click the Convert to New Method 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 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).
Click OK to close the Edit Custom Toolbar Button dialog box and add the toolbar button to the table’s toolbar.