【问题标题】:Close Vaadin notification when click outside of the message box在消息框外单击时关闭 Vaadin 通知
【发布时间】:2014-08-23 10:28:35
【问题描述】:

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

【问题讨论】:

    标签: vaadin vaadin7


    【解决方案1】:

    尝试添加一个使用整个屏幕的标签,这样:

    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());
    }
    

    【讨论】:

      【解决方案2】:

      不,当您使用 setDelayMSec(-1) 时,您必须单击消息框将其关闭。

      如果用户应该能够通过单击框外的任意位置来关闭它,则必须设置一个正数。 当然,您可以设置一个非常高的数字,以便它(几乎)不会自动关闭...

      https://vaadin.com/book/vaadin7/-/page/application.notifications.html

      【讨论】:

      • 谢谢,但是 setDelayMSec() 允许设置通知显示的时间,以毫秒为单位,不依赖于点击!
      • 对不起,你是对的。一旦我们有一个积极的延迟,然后点击内部或超时关闭通知。 Type.HUMANIZED_MESSAGE 可能最接近您想要做的事情。它在鼠标移动时关闭。否则你必须填写 RFE
      猜你喜欢
      • 2018-05-26
      • 1970-01-01
      • 2018-04-19
      • 1970-01-01
      • 2012-09-07
      • 1970-01-01
      • 1970-01-01
      • 2020-11-23
      • 1970-01-01
      相关资源
      最近更新 更多