Adding a blur Listener to close a popup window


Is it possible to add a Blur listener to a window? All i want to achieve is i need to close a window when it looses focus. i.e. when the user clicks anywhere outside the window.
I tried this but seems my popup window does not receive the blur event when the user clicks outside the window. And how can i handle this prioblem in case if my window is a model window?

I guess this should be a pretty straight forward task if i were to use JavaScript. But how to handle this via Vaadin is the problem

Thanks and Regards Kindly help me


this component
fit your needs?


Thanks Johan

I had given a thought about the popup view but the popup should behave as how a model window behaves. i.e. the background window should get disabled.
User should not be able to do any thing in the background window. For example how you open any images on any Facebook page.

Is adding a blur listener to window not possible in vaadin?


You can add a blur listener but the window itself will not “have focus” if some component inside it has focus instead. It should work though if you first click on the “empty” area within your subwindow and then click elsewhere, although it’s not very usable for your use case :(.

As far as I know, this is not possible as you want it without some client-side extension of VWindow. There might be an add-on for this but I haven’t seen one. Have you searched through the directory?

Here’s the relevant code from the Window class:

     * Note, that focus/blur listeners in Window class are only supported by sub
     * windows. Also note that Window is not considered focused if its contained
     * component currently has focus.
     * @see com.vaadin.event.FieldEvents.BlurNotifier
    public void addListener(BlurListener listener) {
        addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener,