You are interested in any key events of an SWT application??
Unfortunately this can’t be done.
You have to add your KeyListener on a given widget. Your listener will receive events when the user types on the keyboard IF AND ONLY IF the listened widget has focus.
If this widget is the only one intersted in key events in your application then it will work perfectly !!!
If you have an other widget intersted in key events, the widget with focus will receive key events but NOT THE 2 widgets.
Focus is set when the user clicks on a widget having at least one KeyListener associated to it. As a consequence the notified listener depends on the user actions … You can also set the focus programmatically using setFocus() method.
For any further informations look here!
November 9, 2008 at 7:29 pm |
Hi Manuel,
there is a way to get this works. Try
Display.getDefault().addFilter(SWT.KeyDown, listener);
and implement a listener that looks like
Listener listener = new Listener() {
public void handleEvent(Event event) {
if (startSequence.getSelection()) {
proceedKeyPress(event);
}
}
};
Don’t forget to unregister your listener on dispose.
Regards,
Dimitri K. E. Missoh.
February 12, 2009 at 12:40 pm |
yes, it works ok, but this event works on all parts of application !