Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » KeyBinding setActive only when ContentOutlinePage
KeyBinding setActive only when ContentOutlinePage [message #826724] Thu, 22 March 2012 08:25 Go to next message
Markus Jo is currently offline Markus Jo
Messages: 83
Registered: January 2012
Member
Hi,
I have a ContentOutlinePage in my RCP Application. The Tree in the outline has a menu with actions. For some of them I have defined a extension key binding.

It really works...but the problem is, that the binding is active even when the outline view does not have the focus.

I think I can solve my problem by setting a contextId in the extension....by I dont know which one. Does the OutlineView has I hard coded id ?
Re: KeyBinding setActive only when ContentOutlinePage [message #826735 is a reply to message #826724] Thu, 22 March 2012 08:44 Go to previous messageGo to next message
Markus Jo is currently offline Markus Jo
Messages: 83
Registered: January 2012
Member
Another problem is, that I have Copy/Paste/Cut actions for this view which use CTRL+C/X/V.....now in my editors this key sequence does not work anymore because it triggers my custom actions.
Re: KeyBinding setActive only when ContentOutlinePage [message #826800 is a reply to message #826735] Thu, 22 March 2012 10:21 Go to previous message
Markus Jo is currently offline Markus Jo
Messages: 83
Registered: January 2012
Member
I found it....

contentOutlineViewer.getControl().addFocusListener(new FocusListener() {

						IContextActivation activateContext;

						@Override
						public void focusLost(FocusEvent e) {
							((IContextService) PlatformUI.getWorkbench().getService(IContextService.class)).deactivateContext(activateContext);


						}

						@Override
						public void focusGained(FocusEvent e) {
							PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable()
							{
							                public void run()
							                {
							                    activateContext = ((IContextService) PlatformUI.getWorkbench().getService(IContextService.class)).activateContext("someContext");
							                }
							            });
						}
					});



And in plugin.xml define the contexts extension point, declare the context.

For each action in your menu, define a command with an id and define a binding to the shortcut you want in your plugin.xml. Set the context attribute. Then, when you create the action in your ActionBarAdvisor, don't set the accelerator. Set the IAction.setActionDefinitionId(*) to the command id and call register(action);

Now you have the Shortcut displayed in the context menu and it is also bound to the key comb......in my case I had to enter "M1+V" as key sequence to work as "CTRL+V"...dont know why.
Previous Topic:LIBDBUSMENU-GTK-CRITICAL on exiting RCP application under Ubuntu 11.10
Next Topic:RCP application architecture
Goto Forum:
  


Current Time: Sat Jul 26 13:29:35 EDT 2014

Powered by FUDForum. Page generated in 0.01535 seconds