简体   繁体   中英

(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.

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)"

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. second, Bind shortcut and command in org.eclipse.ui.bindings extension.

If you do that, shortcut(ctrl+c) will be appeared after the command name.

There are helpful article to see tutorial:

How to make command: http://www.vogella.com/articles/EclipseCommands/article.html

Key binding: 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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