Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » key binding for viewAction
key binding for viewAction [message #447685] Wed, 12 April 2006 12:33 Go to next message
Eclipse UserFriend
Is it possible to setup key bindings for view actions?

All of the information about view actions i've read doesnt mention key bindings.
Its there for popup-menus, but I need some way of defining a key binding for a
button on a particular view's toolbar.

would i have to do something like create a 'normal' action as part of an action
set which would be triggered by the key binding, but for interaction with the
views toolbar i would have my view action implementation invoke this new action?

whats the most straightforward way of achieving this?

thanks,

Martin
Re: key binding for viewAction [message #447687 is a reply to message #447685] Wed, 12 April 2006 12:42 Go to previous messageGo to next message
Eclipse UserFriend
Martin Wood wrote:
> Is it possible to setup key bindings for view actions?

It should be. Create a command for your "action" then use
actionDefinitionId to bind your view action to your command.

Then you can set up a keybinding to your command.

Also check out
http://www.magma.ca/~pollockd/despumate/bindingsHowTo.html for some
handy hints.

Later,
PW
Re: key binding for viewAction [message #447690 is a reply to message #447687] Wed, 12 April 2006 15:02 Go to previous messageGo to next message
Eclipse UserFriend
(oops, meant to reply to the group, not just to you Paul)

Paul Webster wrote:
> Martin Wood wrote:
>> Is it possible to setup key bindings for view actions?
>
> It should be. Create a command for your "action" then use actionDefinitionId
to bind your view action to your command.
>
> Then you can set up a keybinding to your command.

ok, i tried that but using either the actionDefinitionID or definitionID
attribute within the view action declaration brings up an 'illegal attribute'
error, and i hadnt tried this before because its not listed in the specs for a
view action element.

> Also check out
> http://www.magma.ca/~pollockd/despumate/bindingsHowTo.html for some handy hints.

thanks, i've had a read of that a few times today but again, nothing particular
to view actions.

It looks like i'll have to combine a normal action and a view action together in
some way to get what i want..

thanks for the help.

Martin
Re: key binding for viewAction [message #447693 is a reply to message #447690] Wed, 12 April 2006 19:57 Go to previous messageGo to next message
Eclipse UserFriend
Martin Wood wrote:
>
> ok, i tried that but using either the actionDefinitionID or definitionID
> attribute within the view action declaration brings up an 'illegal
> attribute' error, and i hadnt tried this before because its not listed
> in the specs for a view action element.

Sorry, that was editorActions I was thinking of. One possibility is to
create a view action and then use the
getViewSite().getActionBars().getToolBarManager().find(id) to get your
IContributionItem.


*Warning: Hack alert*
If it's an instanceof ActionContributionItem, then you can cast it and
use getAction() to get the IAction. You can set the accelerator and
then use getSite().getKeybindingService() to register your
action+accelerator.
*Warning: Hack alert*

They are all public classes and methods ... but I'm not sure if this
would work or not.


You still might have to go with your approach to get what you want.

Later,
PW
Re: key binding for viewAction [message #447787 is a reply to message #447693] Sat, 15 April 2006 21:30 Go to previous message
Eclipse UserFriend
Martin

You gessed right.

I had sort of the same problem, even a little more complicated because a needed a retargeteable action binded to a key and the only solution I found was to:

1. Create an action (MyAction) and register it in the ApplicationActionBarAdvisor.
2. Create a command (MyActionCommand)
3. Create a key binding for MyActionCommand
4. Add MyAction to your views LocalToolBar, LocalPullDown and ContextMenu.

This should work correctly.

The only problem is that the key binding is not shown in the LocalPullDown nor the ContextMenu. I solved this by putting the key bonding in the ToolTipText.

Good luck.
Previous Topic:Access to ActionbarAdvisor to get list of workbench menus/menu items
Next Topic:Re: keybinding '+' key
Goto Forum:
  


Current Time: Fri Jun 13 16:22:49 EDT 2025

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

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

Back to the top