Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Key binding for action in Eclipse 3.1 ?
Key binding for action in Eclipse 3.1 ? [message #289198] Tue, 02 August 2005 07:58 Go to next message
Martin Olsson is currently offline Martin OlssonFriend
Messages: 20
Registered: July 2009
Junior Member
I would like to bind a keyboard shortcut to one of my actions. This
particular action is a refactoring operation ("Rename...") that operates
on a custom editor that I've implemented myself. This operation is
located in the "Source" menu, which is only visible when an instance of
the custom editor is active.

This is was my best guess so far, I added this to plugin.xml

<extension point="org.eclipse.ui.bindings">
<key sequence="F2"
commandId="defid.source.menu.Rename"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">
</key>
</extension>

But this did not work. Even though I see the action in the source menu
(and can use it by clicking on it), nothing happens when I click the F2
button. Nor does any key binding label appear next to the "Rename..."
menu item.

I've read about a zillion different ways to add key bindings to actions.
Which method is the latest one? I'm using Eclipse 3.1 at the moment.


regards,
martin
Re: Key binding for action in Eclipse 3.1 ? [message #289216 is a reply to message #289198] Tue, 02 August 2005 13:47 Go to previous messageGo to next message
Roland Tepp is currently offline Roland TeppFriend
Messages: 336
Registered: July 2009
Senior Member
I'm not quite shure if the problem is that you are trying to override a
keybinding from org.eclipse.ui plugin or that you are using action id
instead of command id in the binding.

generally speaking - you need to define a command (an extension to
org.eclipse.ui.commands extension point) in your plugin witht the same
ID as commandId attribute value, and specify the same id as definitionId
for your action definition.

The code should look something like this:
<extension point="org.eclipse.ui.commands">
<command id="defid.source.menu.Rename"
name="Rename"
categoryId="Your.category.id"/>
</extension>
<extension point="org.eclipse.ui.bindings">
<key sequence="F2"
commandId="defid.source.menu.Rename"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">
</key>
</extension>
<extension point="org.eclipse.ui.actionSets">
<actionSet ...>
<action id="..."
definitionId="defid.source.menu.Rename"
.../>
</actionSet>
</extension>

(excuse me if there are typos or I've missed something - the exact
syntax is described in documentation for each extensionpoint)

Martin Olsson kirjutas mulle ühel talvisel päeval midagi seesugust:
>
> I would like to bind a keyboard shortcut to one of my actions. This
> particular action is a refactoring operation ("Rename...") that operates
> on a custom editor that I've implemented myself. This operation is
> located in the "Source" menu, which is only visible when an instance of
> the custom editor is active.
>
> This is was my best guess so far, I added this to plugin.xml
>
> <extension point="org.eclipse.ui.bindings">
> <key sequence="F2"
> commandId="defid.source.menu.Rename"
> schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">
> </key>
> </extension>
>
> But this did not work. Even though I see the action in the source menu
> (and can use it by clicking on it), nothing happens when I click the F2
> button. Nor does any key binding label appear next to the "Rename..."
> menu item.
>
> I've read about a zillion different ways to add key bindings to actions.
> Which method is the latest one? I'm using Eclipse 3.1 at the moment.
>
>
> regards,
> martin

--
Roland Tepp
Re: Key binding for action in Eclipse 3.1 ? [message #289428 is a reply to message #289216] Fri, 05 August 2005 00:57 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: user.domain.invalid

Thanks R. That worked right away. Looks like my bindings where colliding
with other JDT bindings just as you suggested. Again... Thanks!


Sincerly,
Martin



Roland Tepp wrote:
> I'm not quite shure if the problem is that you are trying to override a
> keybinding from org.eclipse.ui plugin or that you are using action id
> instead of command id in the binding.
>
> generally speaking - you need to define a command (an extension to
> org.eclipse.ui.commands extension point) in your plugin witht the same
> ID as commandId attribute value, and specify the same id as definitionId
> for your action definition.
>
> The code should look something like this:
> <extension point="org.eclipse.ui.commands">
> <command id="defid.source.menu.Rename"
> name="Rename"
> categoryId="Your.category.id"/>
> </extension>
> <extension point="org.eclipse.ui.bindings">
> <key sequence="F2"
> commandId="defid.source.menu.Rename"
> schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">
> </key>
> </extension>
> <extension point="org.eclipse.ui.actionSets">
> <actionSet ...>
> <action id="..."
> definitionId="defid.source.menu.Rename"
> .../>
> </actionSet>
> </extension>
>
> (excuse me if there are typos or I've missed something - the exact
> syntax is described in documentation for each extensionpoint)
>
> Martin Olsson kirjutas mulle ühel talvisel päeval midagi seesugust:
>
>>
>> I would like to bind a keyboard shortcut to one of my actions. This
>> particular action is a refactoring operation ("Rename...") that
>> operates on a custom editor that I've implemented myself. This
>> operation is located in the "Source" menu, which is only visible when
>> an instance of the custom editor is active.
>>
>> This is was my best guess so far, I added this to plugin.xml
>>
>> <extension point="org.eclipse.ui.bindings">
>> <key sequence="F2"
>> commandId="defid.source.menu.Rename"
>> schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">
>> </key>
>> </extension>
>>
>> But this did not work. Even though I see the action in the source menu
>> (and can use it by clicking on it), nothing happens when I click the
>> F2 button. Nor does any key binding label appear next to the
>> "Rename..." menu item.
>>
>> I've read about a zillion different ways to add key bindings to
>> actions. Which method is the latest one? I'm using Eclipse 3.1 at the
>> moment.
>>
>>
>> regards,
>> martin
>
>
Re: Key binding for action in Eclipse 3.1 ? [message #289441 is a reply to message #289216] Thu, 04 August 2005 22:59 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dcorbin.machturtle.com

Roland Tepp wrote:

> I'm not quite shure if the problem is that you are trying to override a
> keybinding from org.eclipse.ui plugin or that you are using action id
> instead of command id in the binding.
>
> generally speaking - you need to define a command (an extension to
> org.eclipse.ui.commands extension point) in your plugin witht the same
> ID as commandId attribute value, and specify the same id as definitionId
> for your action definition.

What is proper procedure, if some plugin defines a key binding "too
broadly", and you'd like to use the same binding subset context?

David
Re: Key binding for action in Eclipse 3.1 ? [message #289466 is a reply to message #289441] Fri, 05 August 2005 12:02 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: douglas.pollock.magma.ca

David Corbin wrote:
> What is proper procedure, if some plugin defines a key binding "too
> broadly", and you'd like to use the same binding subset context?

Let's say the example is F5 -> Refresh. If you are simply going to
implement functionality that has the same semantic as "refresh" but
localized to the particular context, then you should just override the
handler.

If you are going to change the meaning entirely (e.g., Step Into), then you
define a context. The context should be a child of the context containing
the binding you wish to override. In this way, your binding will be given
priority.

The F5 example is a good one for overriding by context. Cut/copy/paste are
good examples of providing a different handler.



d.
Re: Key binding for action in Eclipse 3.1 ? [message #289509 is a reply to message #289466] Sat, 06 August 2005 00:19 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dcorbin.machturtle.com

Douglas Pollock wrote:

> David Corbin wrote:
>> What is proper procedure, if some plugin defines a key binding "too
>> broadly", and you'd like to use the same binding subset context?
>
> Let's say the example is F5 -> Refresh. If you are simply going to
> implement functionality that has the same semantic as "refresh" but
> localized to the particular context, then you should just override the
> handler.
>
> If you are going to change the meaning entirely (e.g., Step Into), then
> you
> define a context. The context should be a child of the context containing
> the binding you wish to override. In this way, your binding will be given
> priority.
>
> The F5 example is a good one for overriding by context. Cut/copy/paste
> are good examples of providing a different handler.
>
>

The specific case I'm talking about is "CTRL-ALT-X T" Run as JUnit Test. I
want to use it for "Run as Test::Unit Test" if the "selection" is
appropriate (since I don't think the currently selected thing can be both
Java and Ruby at the same time).

I'll look at the context definition.

Thanks.

>
> d.
Re: Key binding for action in Eclipse 3.1 ? [message #289564 is a reply to message #289466] Mon, 08 August 2005 11:55 Go to previous messageGo to next message
Roland Tepp is currently offline Roland TeppFriend
Messages: 336
Registered: July 2009
Senior Member
Ok, but how do I control what is the curtrent application context?

Douglas Pollock kirjutas mulle ühel talvisel päeval midagi seesugust:
> David Corbin wrote:
>
>>What is proper procedure, if some plugin defines a key binding "too
>>broadly", and you'd like to use the same binding subset context?
>
>
> Let's say the example is F5 -> Refresh. If you are simply going to
> implement functionality that has the same semantic as "refresh" but
> localized to the particular context, then you should just override the
> handler.
>
> If you are going to change the meaning entirely (e.g., Step Into), then you
> define a context. The context should be a child of the context containing
> the binding you wish to override. In this way, your binding will be given
> priority.
>
> The F5 example is a good one for overriding by context. Cut/copy/paste are
> good examples of providing a different handler.
>
>
>
> d.
>

--
Roland Tepp
Re: Key binding for action in Eclipse 3.1 ? [message #289576 is a reply to message #289564] Mon, 08 August 2005 13:43 Go to previous message
Eclipse UserFriend
Originally posted by: sunil_kamath.nohotspammail.com

"Roland Tepp" <roland@videobet.com> wrote in message
news:dd7h76$aps$1@news.eclipse.org...
Ok, but how do I control what is the curtrent application context?

Douglas Pollock kirjutas mulle
Previous Topic:How to register a key binding to a IAction
Next Topic:SourceViewConfiguration
Goto Forum:
  


Current Time: Thu Apr 25 23:10:46 GMT 2024

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

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

Back to the top