|How to implement handler for command in main menu and context menu [message #830402]
||Tue, 27 March 2012 15:24
| Jan Krakora
Registered: December 2009
I have a command and I would like to contribute it to the main menu and also to my editor's context menu.
The command should be enabled when some selection occurs.
The problem is that the editor part provide selection variable while the context menu provide activeMenuSelection variable.
How should I create the appropriate handler(s?) and its activeWhen and enableWhen for that command?
[Updated on: Tue, 27 March 2012 15:25]
Report message to a moderator
|Re: Re: How to implement handler for command in main menu and context menu [message #845845 is a reply to message #830940]
||Sun, 15 April 2012 13:24
| Wim Jongman
Registered: July 2009
Hi Jan, |
no, you use two extensions on org.eclipse.ui.menus and assign the COMMAND to
the context menu and the toolbar of the editor.
(btw, the toolbar of the editor will be shown in the main toolbar area).
You do not need to specify any activation expression on the handler because
there is only one handler for the command right?
> Or more specifically, how to deal with this situation:
> There is a command with a default handler.
> The default handler use the active selection from the active workbench
window to work with.
> You would like to add this command to the main menu when is your editor
> You would like to add this command to your editor's context menu.
> Do I need to contribute 2 handlers for this?
> The first one with activeWhen and enableWhen with selection variable check
and the second one with
> activeWhen and enableWhen with activeMenuSelection variable check?
> It could works if my editor provide different selection and context menu
selection, but what if they are equals?
> Which handler will be activated?
Powered by FUDForum
. Page generated in 0.12687 seconds