Search code examples
vaadinvaadin7

Close Vaadin notification when click outside of the message box


setDelayMSec( -1 ) means that the message is displayed until the user clicks on the message box. Can I close to message box when user clicks anywhere outside?


Solution

  • Try to add a tag that uses the entire screen, with this:

    public void createAndShowNotification(String caption, String description, Notification.Type type) {
        description += "<span style=\"position:fixed;top:0;left:0;width:100%;height:100%\"></span>";
        Notification notif = new Notification(caption, description, type, true);
        notif.setDelayMsec(-1);
        notif.show(Page.getCurrent());
    }