Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Switching binding context based on selection
Switching binding context based on selection [message #1685533] Wed, 18 March 2015 22:14 Go to next message
Colin Sharples is currently offline Colin SharplesFriend
Messages: 96
Registered: July 2009
Location: Wellington, New Zealand
Member

I have a graphical editor in an e4 application, and I am trying to get key bindings working so that I can use key shortcuts to call actions on the selected object. There are several different types of object that are represented by different shapes, and these objects are backed by model objects in an inheritance tree. The actions that are available depend on the type of object selected, but I'd like to be able to use the same key shortcut with a different meaning depending on which type of object is selected.

I have defined a different binding context for each of the object types, and associated all of those contexts to the editor view. In the controller where I handle object selection, I have an EContextService reference, which calls deactivateContext and activateContext to ensure that the relevant set of contexts are active.

However, this does not seem to be working.

Let's say I have three object types, Foo, Bar and Qux. Foo and Bar share a common superclass, FooBar, and FooBar and Qux share the superclass FooBarQux. I have five binding contexts relating to each of these classes.

Both Foo and Qux have the key binding CTRL+M (i.e. M1+M) in their binding context, but bound to different commands, "move.foo" and "move.qux" respectively, and each command has its own handler defined. The semantics of moving a Foo and moving a Qux are different, which is why they need to have different commands, even though to the user the CTRL+M command just means "move".

What I see in practice is that if I select a Qux object, the CTRL+M binding will correctly call the move.qux command, but if I then go and select a Foo object, and go back and select the Qux object again, now the CTRL+M binding only ever invokes the move.foo command.

I have debugged through my controller, and have confirmed that it does correctly call the EContextService to activate the correct contexts. It just seems that calling EContextService.deactivateService doesn't properly flush out the current bindings or something.

Is there something else I can do, or is it just a case of not being able to reuse the same key sequence in different contexts?


Colin Sharples
CTG Games Ltd
Wellington, New Zealand
Re: Switching binding context based on selection [message #1692457 is a reply to message #1685533] Wed, 15 April 2015 21:55 Go to previous message
Colin Sharples is currently offline Colin SharplesFriend
Messages: 96
Registered: July 2009
Location: Wellington, New Zealand
Member

Anyone?

Colin Sharples
CTG Games Ltd
Wellington, New Zealand
Previous Topic:E4 Injection/Event System
Next Topic:Eclipse RCP: "File>New" menu emptied after using the same menu in the toolbar
Goto Forum:
  


Current Time: Tue Mar 19 11:30:01 GMT 2024

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

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

Back to the top