Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [recommenders-dev] Capture a mouse click action outside a shell widget

Not sure whether this is the best solution but this should work:


        Display.getDefault().addFilter(SWT.FocusOut, new Listener() {

            @Override
            public void handleEvent(Event event) {

                for (Control c = (Control) event.widget; c != null; c = c.getParent()) {
                    if (c == myOwnPopupShell) {
                        System.out.println("we lost focus");
                        break;
                    }
                }
            }
        });


You may extend the listener to know which other shells exist you want to listen too. Please note that the listener MUST be unregistered as soon as the popup is disposed. Let me know whether this helps.


Marcel

On Jul 14, 2013, at 11:30 AM, Madhuranga Lakjeewa <lakjeewadmm@xxxxxxxxx> wrote:

> It didn't work for me. When we have some widgets inside the shell, the focus is gained by them. The shell widget lose the focus even when the focus is gained by a widget which is inside of it.



Back to the top