Skip to main content



      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 18:45 Go to next message
Eclipse UserFriend
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 05:33 Go to previous messageGo to next message
Eclipse UserFriend
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 07:41 Go to previous message
Eclipse UserFriend
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 Jun 08 10:22:14 EDT 2025

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

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

Back to the top