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);

	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
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 741
Registered: January 2012
Senior Member

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().


Eclipse Platform committer. Ask me about Eclipse support, training, and consulting.
Previous Topic:Inconsistent table height behavior
Next Topic:Canvas on Ubuntu 14 not working?
Goto Forum:

Current Time: Sun May 20 16:06:44 GMT 2018

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

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

Back to the top