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

Thank you very much Marcel.

This did not exactly work for my purpose. Because I have two shells and when i change the focus between them it captures that event also as a focus lost (which is correct. But i want both shells open when i go in between them).

Here is what i did;

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

@Override
public void handleEvent(Event event) {
if (event.widget.equals(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()))
                        System.out.println("we lost focus");
myOwnPopupShell.dispose();
}

        });

This captures the click action on the active editor. Then i can dispose all the shells. At the end i remove the listener.

Thank you very much for the support.

Regards,
Madhuranga



On Sun, Jul 14, 2013 at 7:46 PM, Marcel Bruch <marcel.bruch@xxxxxxxxxxxxxx> wrote:
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.

_______________________________________________
recommenders-dev mailing list
recommenders-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/recommenders-dev


Back to the top