Alter Context Menu Depending on SelectedObject
This application registers a ShellUI module that declares a command which is only available when a single object is selected and the context menu (right-click menu) opened.
This approach can be used to filter commands to only show - for example - if objects of a certain type are selected when the context menu is triggered.
- The application consists of two files:
appdef.xml, which declares the application contents.
main.js, a ShellUI module, which creates a command (menu item) and attaches it to the context menu.
The application broadly takes the following approach:
- When the shell frame is started, the code creates a command and adds it to the context menu.
- When the
IShellListing.OnShowContextMenuevent is fired, the system checks how many items are selected and shows or hides the command accordingly:
- If there is only one item selected then the command is visible.
- If there are zero items selected, or more than one item selected, the command is hidden.
Testing and deploying
The simplest method to test an application is to copy the files into a local development folder. This allows you to alter the files and simply log out and into the vault to see the changes.
To deploy the application, you must zip the application files and deploy them using the M-Files Admin tool. This process is detailed on the M-Files Developer Portal.
When a client connects a vault, new User Interface Extensibility Framework applications will be downloaded and the user will be prompted to install them. This can be avoided by pre-approving it using registry keys.