菜单处理程序
我已在我的 Eclipse RCP 应用程序中创建了菜单贡献作为扩展( org.eclipse.ui.menus)。此菜单贡献的项目是通过处理程序作为命令进行的。我不仅希望为项目(命令)提供这样的处理程序,还希望为包含其项目的菜单(例如“文件”、“编辑”...)提供这样的处理程序。
菜单在 plugin.xml
中可以有一个“commandID”字段。我尝试使用扩展了 AbstractHandler 的 Handler 创建具有此 ID 的命令,但它不起作用。
I have created the menu contribution in my Eclipse RCP application as an extension (org.eclipse.ui.menus
). The items of this menu contribution are made as commands with handlers. I want to have such handlers not only for items (commands), but also for menus which are containing their items too (such as "File", "Edit"...).
The menus can have a field "commandID" in plugin.xml
. I tried to create the command with this ID with a Handler extended the AbstractHandler, but it does't work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
菜单可以采用 commandId,以便可以显示快捷键。那部分只是为了显示方便。要使菜单自动弹出,还需要在幕后做一些工作。
了解如何在 org.eclipse.ui.ide 插件中定义和使用命令
org.eclipse.ui.navigate.showInQuickMenu
。它在 org.eclipse.ui.internal.ide.WorkbenchActionBuilder 中还有一些支持代码:
Menus can take commandIds so they can display a key shortcut. That part is simply a display convenience. There's still work to do behind the scenes to make the menu auto-popup.
See how the command
org.eclipse.ui.navigate.showInQuickMenu
is defined and used in the org.eclipse.ui.ide plugin.It also has some supporting code in the
org.eclipse.ui.internal.ide.WorkbenchActionBuilder
: