Question

Im am making an Java SWT program that is required to run on both Linux and Windows.

I use the following Code to listen for KeyUp events:

Control.addListener(SWT.KeyUp, new Listener() {

public void handleEvent(Event arg0) {
 System.out.println("Event");

}

});

But this does not trigger when no control has focus.

Do anyone know of a place i can add a listener that acts as a Catch-all?

Was it helpful?

Solution 3

I have not been able to find a solution to this. I suspect none exist

OTHER TIPS

The only way of doing this that I'm aware of is by placing a filter on the Display. Take note that multiple Shells may operate on one Display, so you should be careful!

shell.getDisplay().addFilter(SWT.KeyDown, new Listener() {
    public void handleEvent(final Event event) {
        System.out.println(event);
    }
});

try following method in Display class:

public void addListener ( int eventType, Listener listener ) 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top