Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Key Binding Conflict Question
Key Binding Conflict Question [message #330438] Mon, 28 July 2008 18:35 Go to next message
Eclipse UserFriend
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 08:58 Go to previous messageGo to next message
Eclipse UserFriend
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 10:50 Go to previous message
Eclipse UserFriend
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: Thu May 01 13:40:30 EDT 2025

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

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

Back to the top