Close Modal Window when background clicked.

I have a modal window that I need to close when the background is clicked. Is there a way to attach a click listener to the background?

You could add a click listener to the UI. But in this case your window couldn’t be a modal, but a simple window.

    final Window window = new Window("My window");

    addClickListener(new ClickListener() {
        public void click(com.vaadin.event.MouseEvents.ClickEvent event) {

Thanks Felype, but in this istance I actually do need it to be a modal. I think the best work around that I can find is the use the keyboard escape shortcut and just make sure the users now this is another option. Funny how clicking to
is too much of a hassle.