英文:
How to hide some sub-menu items
问题
你好,
我已经创建了一个包含5个子菜单的菜单。但在某些情况下,我只想显示其中的3个子菜单。除了生成一个新菜单外,是否可以使用一些标志来显示所需的子菜单?
谢谢
陈 ZX
英文:
all:
I have create a menu with 5 sub-menus. But in some case, I only would like to display 3 of these sub-meunus. Besides generating a new menu, is that possible to use some flag to display the needed sub-menus?
Regards
Chen ZX
答案1
得分: 2
在DM中,菜单对象没有确定菜单项是否可见的“flag”属性。更好的方式是将菜单对象视为全局可访问的资源,可以根据DM应用程序中发生的事件动态修改。换句话说,当条件满足时,您希望子菜单的可见性发生变化(您必须通过事件或定期执行的脚本进行检测),然后您需要获取受影响的菜单对象的引用,并通过AddMenuItem方法添加所需的子菜单,或通过RemoveMenuItem方法删除它们。
另一种方法是通过在子菜单上使用SetIsEnabled方法来禁用子菜单。虽然这不会删除子菜单,但会使其变灰,并阻止与其相关联的任何代码通过用户操作触发。
有关DM菜单的脚本接口的详细信息,请参阅在线帮助路径Scripting > Objects > Menus。
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论