Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Problem Binding action to shortcut programatically
Problem Binding action to shortcut programatically [message #334305] Mon, 02 February 2009 11:37 Go to next message
Eclipse UserFriend
Hi-ya

I have an action that I am having trouble programmatically binding to a
key binding.

As shown below, I am defining the command, and defining a key binding, and
then in the constructor of the action I am calling setActionDefinitionId
with the id of the command (BLAH). In a view I am setting the global
action handler with the action and updating the action bars.

The key binding seems be registered ok, when I press ctrl-shift-l I can
even see it. But if I click on it or press CTRL+SHIFT+3 nothing happens,
as if the action is not enabled. However I have also ensured that enabled
is always true.

This is perplexing, what could I be doing wrong? Or where could I set a
break point to see what happens when I press CTRL+SHIFT+3?

Thanks.
########## Code #########

<extension point="org.eclipse.ui.bindings">
<key sequence="CTRL+SHIFT+3"
commandId="BLAH"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
contextId="org.eclipse.ui.contexts.window" />
</extension>

<extension
point="org.eclipse.ui.commands">
<command
id="BLAH"
name="Hello">
</command>
</extension>

// Code in View
getViewSite().getActionBars().setGlobalActionHandler(newFall Action.getId(),
newFallAction);
getViewSite().getActionBars().updateActionBars();
Re: Problem Binding action to shortcut programatically [message #334336 is a reply to message #334305] Tue, 03 February 2009 14:02 Go to previous message
Eclipse UserFriend
setGlobalActionHandler(*) is the old mechanism for global retarget
actions, but is not generally used for keybindings.

Instead try:

IHandlerService hs
= (IHandlerService)getSite().getService(IHandlerService.class) ;
hs.activeHandler(newFallAction.getActionDefinitionId(),
new ActionHandler(newFallAction));

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.platform.doc.isv/guide/workbench.htm
Previous Topic:newWizard categories
Next Topic:Original Tasks View missing in 3.4 with Mylyn
Goto Forum:
  


Current Time: Thu Mar 13 16:12:43 EDT 2025

Powered by FUDForum. Page generated in 0.02652 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top