Using Smart Buttons & Scripted Buttons
Use Smart Buttons if you want to add buttons to navigate among canvases, or to open a perspective, or update Data Imports, without having to write any scripts at all. When you use smart buttons, you simply select the button type and action you want the button to perform.
If you want to write your own Custom scripts for scripted buttons, please see Scripted Buttons for Canvas Presentations below.
Smart Button Canvas and Perspective Navigation and Data Import Updates
The underlying methods that support "smart buttons" for navigation on canvases and perspectives, and to update Data Imports are available to users who want to write their own scripts (see the scripted buttons section below). However, you can use Modeler's pre-built smart buttons. For canvas navigation, Next, Previous, Open Canvas and Open Perspective smart buttons are pre-built and require no script-writing. An additional advantage to using the Open Canvas and Open Perspective smart buttons is that these buttons won't lose the association to the canvas or perspective you associate with them even if the canvas or perspective gets renamed. Just select the navigation type (Previous, Next, Open Canvas, Open Perspective). For updating Data Imports, pre-built Update Selected and Update All smart buttons are available.
![]() |
![]() |
Note that you can filter in the Edit Button dialogs.
Next and previous navigation is determined based on the Model Browser folder structure. If you use Next, for example, the script method looks at the folder structure to find the next canvas in the model browser.
You can also open a specific named canvas using the smart button called Open Canvas. When you choose Open Canvas, the available canvases display for selection and you simply choose the canvas to open. The Open Perspective smart button works like Open Canvas: select the perspective to associate with the Open Perspective button.
The underlying methods that support "smart buttons" for are available to users who want to write their own scripts (see the scripted button section below).
Smart Button Usage Notes
- The available smart buttons for Navigation include Next, Previous, Open Canvas and Open Perspective.
- The available smart buttons for Data Import include Update Selected and Update All.
- Open Canvas shows the available canvases in the Edit button pane, under Select Canvas.
- Update Selected Data Imports shows the available data imports in the Select Matrices to Update pane.
- The button(s) are disabled if there is no next or previous relative to the location from which you are trying to navigate.
- You cannot access the underlying scripts for smart buttons.
- You cannot open a specific canvas or update a data import unless you have adequate permissions.
- You can change the button labels from the Smart button dialog. Select the button on the canvas, right-click and choose Properties, then use the label field. Note that you can also rename Perspective smart buttons using the Modeler toobar Perspectives option to Manage Perspectives > Rename.
- You can still use the Custom Script button if desired.
Note regarding Data Import Smart Buttons
You can choose whether to have updates use Embedded Credentials (as might be used for a service account based import) or not, which means using either a local credential if the app is used in Modeler, or prompting users for credentials for username/password, or done via OAuth credentials.
Scripted Buttons for Canvas Presentations
You might write an action to perform a transformation on a model that you could use while presenting your data. In that situation, you would like to be able to invoke the action as fluidly as possible during your presentation. With Quantrix, you can connect an action to a scripted button on a presentation canvas in Layout mode, so you can invoke the action by clicking the button in Interact mode. The steps below show you how to create a presentation canvas that uses the Parity Check action. Provided you have created a model with the parity check script in a previous step, you can use that model to walk through this step.
Start by creating a new presentation canvas and adding a table view to it for Matrix1, as follows:
1. Add a new presentation canvas to the model by clicking the Insert Presentation Canvas toolbar button.
2. Add a table view for Matrix1 by clicking the Insert Canvas Table View toolbar button, selecting Matrix1 from the resulting dialog, and clicking within the canvas.
3. You can add the scripted button from the Canvas toolbar, or from the Script Manager. The Canvas toolbar has an Add Scripted button icon:
If you click the Add Scripted button, you see the Parity Check script under Custom Script.
Note that you can create your own button label rather than use the default label that is the same as the action name. To create your own label remove the check mark from Use Script Name as Label and enter your own button label.
You can change the button label at any time by right-clicking on the button, choosing Properties, and changing it in the Rename pane.
You can also open the Script Manager and (assuming the Parity Check action is written) drag the Parity Check action onto the canvas. A button is automatically created with the label “Parity Check”. You may need to resize the button before the entire label will be visible.
4. Click the Layout button on the canvas toolbar to switch to Interact mode.
5. Test your new scripted button. Enter a value into the cell A1:B1 on the canvas and click the Parity Check button. The action is invoked and the result displays.
Scripting notes
Canvas Navigation & Data Import Methods
Below are the methods underlying the navigation and Data Import smart buttons that you can, if desired, use to write your own scripts:
nextPresentation() - Returns the next presentation in the same Model Browser folder as this view. Returns null if no presentation exists after this view in the enclosing folder.
previousPresentation() - Returns the previous presentation in the same Model Browser folder as this view. Returns null if no presentation exists before this view in the enclosing folder.
openPerspective(String name) - Opens the perspective with the given name, if it exists.
closeAllViews closes all open Matrices, Canvases, Charts, and Scripts.
closeAllToolPanes closes all open tool panes, which include the Model Browser, Script Manager, Format Toolbox and others.
void updateSelectedImportMatrices(Collection<Matrix> importMatrices)
Update a collection of import matrices and refresh all their sources. This will handle ordering the imports and refreshes to ensure that each refresh happens only once and any imports that depend on others will be updated later. If there are calculations involved as well, that will not be taken into account and must be handled manually instead. Requires appropriate permissions and authentication (see performWithEmbeddedCredentials())
Workflow to Update Data Import on the Qloud
Below is the general workflow involved:
-
Create a model with a matrix and set up the Data Import data source
-
Insert a canvas using the matrix and add a scripted button that uses performStoredCredentials that updates Data Import.
-
Verify that the scripted button updates the data within Quantrix Modeler.
-
Publish the model to the Qloud and verify that the scripted button updates the data.
-
Share the model, ensuring that the users who need to update the Data Import have appropriate permissions.
Using a Privileged Method
It is possible to allow a user to execute a script that runs on a hidden view, by using a privileged method{} in the script. For example, if the user has no permission to open Matrix1, but the script needs to get values from Matrix1:
GroupOrItemSelection selection
privileged
{
selection = |Matrix1::A1..A3|
}
selection.values
Using Pipe Selection for Canvas Navigation
You can use pipe selection to support canvas navigation: you can select a matrix view from a canvas using pipe selection on the matrix name, get a list of canvas objects from a canvas, and select cells, nodes, ranges, and item descriptors using extended pipe selection from a matrix canvas object. For example,
|Canvas1::Matrix1::A1|.backgroundColor = "FF0000"
alert(|Canvas1::Matrix1|)
|Canvas1::Rectangle2|.text = "{Matrix1::A1}"
|Matrix1|.filterTrayCategories.add(|Matrix1::A|)
|Canvas1|.filterTrayCategories.add(|Matrix1::A|)
Assigning Hotkeys to Actions
If you use an action often enough, you may want to assign a hotkey to it so that you can invoke it using a keyboard shortcut. Quantrix allows you to assign the numbers 0 through 9 as hotkeys for up to ten actions in a model. To run an action using its hotkey, hold the Ctrl key on Windows or the Command key on macOS and then press the appropriate number key. You can assign a hotkey to an action using the hotkey button in the action editor. The button displays the shortcut for the currently assigned hotkey or the text “None” if no hotkey is assigned. An action can be assigned a hotkey only if it is showing in the scripting menu (that is, if its Scripting Menu checkbox is enabled in the action editor).
Below is the Hotkey assignment that displays when you click the Hotkey button: