Dynamic menu contribution with key bindings

删除回忆录丶 提交于 2019-12-25 01:16:44

问题


I've a question. I have a dynamic menu contribution (class extending the ContributionItem). But I cannot find how to connect these items with key bindings.

The main problem is, that the plugin is actually quite easy. It loads menu from XML file. Practically it is a horror, because there is just few tutorials about dynamic menus. Almost every tutorial uses plugin.xml. But I cannot do it this way. I need to load items from a XML file depending on the workspace choosen. The file contains menu structure including key bindigs. That's my problem. I've never found how to bind keys with commands dynamically.


回答1:


Fortunately the menu item has a method, wich can be used to get this task done:

MenuItem menuItem = new MenuItem(menu, SWT.CHECK, index);
menuItem.setAccelerator(SWT.SHIFT | SWT.ALT | 'G');

Nevetheless to get list of the key bindings already used in current Eclipse instance is not so trivial. Most likely they must be instpected by going through list of plugins and their menu contributions.



来源:https://stackoverflow.com/questions/10028967/dynamic-menu-contribution-with-key-bindings

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!