简体   繁体   English

(Eclipse RCP)如何在工具栏中的菜单项之后添加快捷方式文本?

[英](Eclipse RCP) How can I add shortcut text after a menu entry in toolbar?

I want to add shortcut text after the menu entry in toolbar. 我想在工具栏的菜单项之后添加快捷方式文本。

For example, for "copy" menu entry in toolbar, default only a image in toolbar, and the tooltips will be "Copy (Ctrl+C)", what I need is adding "Ctrl + C" after the image of Copy menu entry, I did a lots of search, but can't find more useful material. 例如,对于工具栏中的“复制”菜单项,默认情况下仅工具栏中的图像,并且工具提示将为“复制(Ctrl + C)”,我需要在“复制”菜单项的图像后添加“ Ctrl + C” ,我进行了大量搜索,但找不到更多有用的材料。

Also the action ( such as Copy ) has a shortcut, for example, "Ctrl + C", when our mouse hovers on the menu entry, will show "Copy (Ctrl+C)", but when I use Action.getText(), I only can get "Copy", not "Copy (Ctrl + C)" 此外,操作(例如Copy)也具有快捷方式,例如“ Ctrl + C”,当我们的鼠标悬停在菜单条目上时,将显示“ Copy(Ctrl + C)”,但是当我使用Action.getText()时,我只能得到“复制”,而不是“复制(Ctrl + C)”

Thanks for your help, this issue troubled me couple days. 感谢您的帮助,这个问题困扰了我几天。

You can show shortcut easily by using command, action and binding. 您可以使用命令,操作和绑定轻松显示快捷方式。

First. 第一。 Create command in org.eclipse.ui.commands extension. 在org.eclipse.ui.commands扩展名中创建命令。 second, Bind shortcut and command in org.eclipse.ui.bindings extension. 其次,在org.eclipse.ui.bindings扩展中绑定快捷方式和命令。

If you do that, shortcut(ctrl+c) will be appeared after the command name. 如果这样做,则快捷方式(ctrl + c)将出现在命令名称之后。

There are helpful article to see tutorial: 有一些有用的文章可以查看教程:

How to make command: http://www.vogella.com/articles/EclipseCommands/article.html 如何进行命令: http : //www.vogella.com/articles/EclipseCommands/article.html

Key binding: http://www.vogella.com/articles/EclipseCommandsKeybindings/article.html 按键绑定: http : //www.vogella.com/articles/EclipseCommandsKeybindings/article.html

It looks strange and difficult but if you master eclipse command, it will be one of the most powerful extension in RCP development. 它看起来很奇怪而且很困难,但是如果您掌握了eclipse命令,它将成为RCP开发中最强大的扩展之一。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM