SWT Key Events on Display - Focus Management

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!

Leave a Reply