We’ve previously covered how you can utilize CUI to add custom buttons to toolbars. However, you can also take advantage of CUI to add keyboard shortcuts for more advanced users. In this blog post, we will cover how to add a shortcut to select all of the items in a grid when a user presses “Ctrl+A”.
You can find all of the code in this blog post in the cui-shortcut project on the Aras Labs GitHub.
Note: This project will should only be used with Aras 11 SP7 and later. The necessary CUI capabilities were not yet implemented in versions earlier than 11.0 SP7.
Create the Shortcut Handler
We will begin with writing the Method that will select all of the items in the grid.
- This follows the naming conventions of the other shortcuts which will make it easier to find in the future
- MWS stands for “Main Window Shortcut”
- Copy and paste the code from the editor below into this new method
- Save, unlock, and close the my_mws_ctrl_a method
Adding the Shortcut
- In the TOC, navigate to Administration > Configuration > Client Presentation and click the hyperlink highlighted below
- In the Command Bar Section relationship tab, search for the item below
- Classification: Data Model
- Name: com.aras.innovator.cui_default.main_window_main_menu
- Location: Main Window Main Menu
- Open and lock this item
- In the Command bar Item relationship tab, create a new item with the information below
- ItemType: Shortcut
- Name: my.cui.mws_ctrl_a
- Action: Add
- For Identity […]: World
- This is the group of users that will be able to use this shortcut
- Right-click > View “Command Bar Item” to view this shortcut in a new window
- Fill in the following information
- Handler: my_mws_ctrl_a
- Shortcut: ctrl+a
- Save, unlock, and close this Shortcut
- Save, unlock, and close the Command Bar Section
You can now try out this new shortcut by selecting any ItemType in the TOC and clicking ctrl+a. You should see that all of the items in the grid are selected.