Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Why Display.addFilter doesn't works with hotkeys?
Why Display.addFilter doesn't works with hotkeys? [message #1400710] Mon, 14 July 2014 16:01 Go to next message
Vyacheslav Petrov is currently offline Vyacheslav PetrovFriend
Messages: 1
Registered: July 2014
Junior Member
Hi, folks!

I develop plugin, and I need to detect every each key presses.
I have created listener

public class ActionsRecorder implements Listener {
	public void handleKeyPress() throws ExecutionException {
	    Display display = Display.getCurrent();
	    if (display == null) {
	    	display = Display.getDefault();
	    }
     	   display.addFilter(SWT.KeyDown, this);
	}
	

	@Override
	public void handleEvent(Event event) {
		System.out.println("sausage! " + event);
	}
}


So, if I press ctrl + "b", everything works correct.
But if I press ctrl + "a", event is not handled, because hotkey action called instead of my filter. What I do wrong?
Re: Why Display.addFilter doesn't works with hotkeys? [message #1401445 is a reply to message #1400710] Tue, 15 July 2014 16:24 Go to previous message
Eclipse UserFriend
The Eclipse Workbench installs a key-detect listener to implement its keybindings, and its "eats" the keys that are matched to a key binding. It's likely this key-detect listener is being called first.

If you're on Eclipse 4.x, you can obtain the KeyBindingDispatcher instance and disable its key filter, log the keystrokes, and then call the KeyBindingDispatcher#press().

Brian.
Previous Topic:Inconsistent table height behavior
Next Topic:Canvas on Ubuntu 14 not working?
Goto Forum:
  


Current Time: Thu Apr 25 17:27:08 GMT 2024

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

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

Back to the top