dm-script

How Can I Hide Some Sub-Menu Items Without Creating a New Menu?


I have created a menu that includes 5 sub-menu items. However, in some cases, I only want to display 3 of these sub-menu items. Instead of generating an entirely new menu, I’m wondering if there’s a flag or parameter that allows me to control which sub-menu items are displayed.

What I’ve Tried:

Questions:

Any insights, examples, or alternative approaches would be greatly appreciated.


Solution

  • Menu objects in DM do not have "flag" properties that determine whether menu items are visible. A better way to think of a Menu object is as a globally accessible resource that can be dynamically altered in response to events that occur within the DM app. In other words, when conditions are such that you want the sub-menu visibility to change (which you must detect either via an event or some test done by a periodically executed script), then you need to get a reference to the affected menu object and add the desired sub-menus via the AddMenuItem method or remove them via the RemoveMenuItem method.

    Another approach is to simply disable the sub-menus by using the SetIsEnabled method on them. Although this does not remove the sub-menus, it does gray them out and prevents any code connected to them from being triggered through user actions.

    Details about the script interface to DM's menus are provided in the on-line help at the path Scripting > Objects > Menus.