Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Getting current KeyBinding in Handler's @Execute method
Getting current KeyBinding in Handler's @Execute method [message #1722093] Tue, 02 February 2016 17:21 Go to next message
Jani Simomaa is currently offline Jani SimomaaFriend
Messages: 3
Registered: February 2016
Junior Member
Hello everyone!

I am migrating an Eclipse 3.x application to E4 and currently I'm working with KeyBindings and Handlers.

I wonder if it is possible to get the KeyBinding that launched the associated Handler. My Handler looks like the following:

    @Execute
    public void execute(@Optional MKeyBinding binding) {
        // Here binding is always null
    }


The reason why I would like to have the keybinding is that the same handler is shared between few other KeyBindings and the application logic depends on the current binding.

I'm aware that it is possible (and maybe suggested) to make every KeyBinding have it's own handler but I would not like to do that if necessary.

Thanks!
Re: Getting current KeyBinding in Handler's @Execute method [message #1722111 is a reply to message #1722093] Tue, 02 February 2016 19:14 Go to previous messageGo to next message
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 876
Registered: January 2012
Senior Member

Look into using a command parameter to differentiate your cases. Your command can be invoked programmatically, so relying on a keybinding is not a good practice.

Brian.


Eclipse Platform committer. Ask me about Eclipse support, training, and consulting.
Re: Getting current KeyBinding in Handler's @Execute method [message #1722165 is a reply to message #1722111] Wed, 03 February 2016 08:11 Go to previous message
Jani Simomaa is currently offline Jani SimomaaFriend
Messages: 3
Registered: February 2016
Junior Member
This was exactly what I was looking for and feels like a correct way of doing things. Thanks!
Previous Topic:Use of Jface TextViewer in E4 app
Next Topic:Programmatically minimize/restore PartStacks
Goto Forum:
  


Current Time: Sat Sep 19 20:30:31 GMT 2020

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

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

Back to the top