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!

Advertisements

2 thoughts on “SWT Key Events on Display – Focus Management

  1. 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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s