Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » How to assign keys to an action
How to assign keys to an action [message #301230] Fri, 24 March 2006 23:45 Go to next message
Alex Le is currently offline Alex LeFriend
Messages: 649
Registered: July 2009
Senior Member
Hi,

I am contributing an action to the workbench toolbar for my editor would
like to be able to associate the keystrokes that will activate the
action, for example, pressing ALT+F8 to turn on my action.

I am using the below extension point.

<extension point="org.eclipse.ui.editorActions">
<editorContribution
....

I have read the article
http://www.eclipse.org/articles/Article-action-contribution/ Contributing%20Actions%20to%20the%20Eclipse%20Workbench.html
from Eclipse.org, but it does not discuss how one would associate/assign
key to an action.

Thanks for any tips or examples.
Re: How to assign keys to an action [message #301272 is a reply to message #301230] Mon, 27 March 2006 10:33 Go to previous messageGo to next message
Chris is currently offline ChrisFriend
Messages: 10
Registered: July 2009
Junior Member
Use the definitionID attribute of the action in the plugin.xml.

Then when you create the /view/editor you can do something like:

viewer.getControl().addKeyListener(new KeyAdapter(){
public void keyReleased(KeyEvent evt){
if (evt.character == SWT.F8 && evt.statemask == SWT.ALT){
...//run your action
}
}
}

Hope this helps
Re: How to assign keys to an action [message #301279 is a reply to message #301230] Mon, 27 March 2006 12:41 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

AL wrote:
> Hi,
>
> I am contributing an action to the workbench toolbar for my editor would
> like to be able to associate the keystrokes that will activate the
> action, for example, pressing ALT+F8 to turn on my action.
>
> I am using the below extension point.
>
> <extension point="org.eclipse.ui.editorActions">
> <editorContribution
> ...
>

You can link an action to a command (org.eclipse.ui.commands) using the
actionDefinitionId and then map a key to the command using
org.eclipse.ui.bindings

Also, check out http://www.magma.ca/~pollockd/despumate/bindingsHowTo.html


Later,
PW


Previous Topic:QuickFix for my editor
Next Topic:Class files
Goto Forum:
  


Current Time: Sun Oct 06 12:40:38 GMT 2024

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

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

Back to the top