Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Key Binding Conflict Question
Key Binding Conflict Question [message #330438] Mon, 28 July 2008 22:35 Go to next message
Mike Bernat is currently offline Mike BernatFriend
Messages: 12
Registered: July 2009
Junior Member
I am using the org.eclipse.ui.menus extension to define some context menu
commands and I have a pair of items that are mutually exclusive WRT their
visibleWhen expressions and their handler's activeWhen/enableWhen
ecpressions. I would like to be able to assign the same key binding to
each, but I cannot get past the key binding conflict. Is there anything in
the extension points that would allow this, or is there a programmatic way
to get past this?
Re: Key Binding Conflict Question [message #330449 is a reply to message #330438] Tue, 29 July 2008 12:58 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

The keybindings themselves are static in nature (i.e. they are not
enabled/disabled by command state, but simply do nothing if the command
is disabled).

Depending on what you want to accomplish, one possibility is to create a
context using org.eclipse.ui.contexts that is a sub context of an
appropriate context (like org.eclipse.ui.window). When your context is
active, that keybinding defined in that context will override a
keybinding defined in the org.eclipse.ui.window context.

Then you would just say "Command A is the common case, CTRL+5 A in
window, Command B is the other case, CTRL+5 A in my.context"

Then when appropriate, you would use the IContextService to activate
my.context.

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/help33/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm


Re: Key Binding Conflict Question [message #330501 is a reply to message #330449] Wed, 30 July 2008 14:50 Go to previous message
Mike Bernat is currently offline Mike BernatFriend
Messages: 12
Registered: July 2009
Junior Member
Hi Paul,

Thanks for this suggestion. I ended up using a single
command/handler/binding, and used the dynamic contribution mechanism to
set different strings in the menu based on the state of the selection. The
handler also used this state to route to the desired behavior.

Mike

Paul Webster wrote:

> The keybindings themselves are static in nature (i.e. they are not
> enabled/disabled by command state, but simply do nothing if the command
> is disabled).

> Depending on what you want to accomplish, one possibility is to create a
> context using org.eclipse.ui.contexts that is a sub context of an
> appropriate context (like org.eclipse.ui.window). When your context is
> active, that keybinding defined in that context will override a
> keybinding defined in the org.eclipse.ui.window context.

> Then you would just say "Command A is the common case, CTRL+5 A in
> window, Command B is the other case, CTRL+5 A in my.context"

> Then when appropriate, you would use the IContextService to activate
> my.context.

> PW
Previous Topic:Re: Listening for a page change
Next Topic:[RSA][Plugin Dev][Modeling] Properties view
Goto Forum:
  


Current Time: Sun Jun 30 13:44:03 GMT 2024

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

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

Back to the top