单击消息框外部时关闭Vaadin通知

erw*_*win 3 vaadin vaadin7

setDelayMSec(-1)表示在用户单击消息框之前显示消息.当用户点击外面的任何地方时,我可以关闭消息框吗?

Kra*_*ayo 6

尝试添加使用整个屏幕的标记,使用:

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());
}
Run Code Online (Sandbox Code Playgroud)