Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Guillaume on July 11, 2014, 04:38:13 pm
-
Hi,
I'm moving a number of VB scripts (normal, project browser, diagram) into an EA add'in.
I'm looking for a set of conditions to display menus based on the selection context, e.g.
Menu1 : displayed if Extension accessed via a right click from a diagram
Menu2 : displayed if Extension accessed via a right click from the project browser
Menu3 : always displayed
Have you got any recommendation? The current template only checks if an EA Project is opened to enable/disable the whole menu.
Thanks
-
The GetMenuState instruction includes a value for Location which can be TreeView, MainMenu or Diagram.
You can use a Case statement to determine which and then display sub menus accordingly.
There’s a simple example in the current version of the EA Manual on Page 2566.
What I haven’t yet figure out is whether I can use the Add In to change the native EA Main Menu: for example to remove features that are superfluous to my user.
-
Both EA_GetMenuItems and EA_GetMenuState have a Location parameter. Possible values: "MainMenu", "Diagram", "TreeView".
You could either test the Location value in EA_GetMenuItems to decide whether or not to show each menu item at all, or test the Location value in EA_GetMenuState to disable (i.e. grey out) your menu options.
The add-in cannot change any native menus outside of it's own submenu below Extensions. If you wish to show/hide other EA menu options, please see the help regarding the "Command Sets" feature.
http://www.sparxsystems.com/enterprise_architect_user_guide/10/getting_started/customize_command_sets.html