【问题标题】:GWT notification widget?GWT 通知小部件?
【发布时间】:2011-05-17 19:06:39
【问题描述】:

你知道那里是否有任何 GWT 的通知小部件,比如这里的这个?

http://demo.vaadin.com/sampler#NotificationHumanized

【问题讨论】:

    标签: gwt gwt-widgets


    【解决方案1】:

    AFAIK 在核心 GWT 中没有这样的小部件,但为什么不自己推出:

    public class DelayedPopup extends PopupPanel {
    
        public DelayedPopup(String text, boolean autoHide, boolean modal) {
            super(autoHide, modal);
            setWidget(new Label(text));
        }
    
        void show(int delayMilliseconds) {
            show();
            Timer t = new Timer() {
                @Override
                public void run() {
                    DelayedPopup.this.hide();
                }
            };
    
            // Schedule the timer to close the popup in 3 seconds.
            t.schedule(3000);
        }
    }
    

    这不是我的想法,所以它可能无法编译,但你明白了。

    更新:

    根据评论,我正在添加在鼠标移动时隐藏自身的通知:

    public class Notification extends PopupPanel {
    
        public Notification(String text) {
            super(false, false);
            setWidget(new Label(text));
        }
    
        @Override
        public void show() {
            installCloseHandler();
            super.show();
        }
    
        public native void installCloseHandler() /*-{
            var tmp = this;
            $wnd.onmousemove = function() {
                // edit the com.google.gwt.sample.contacts.client package 
                // to match your own package name
                tmp.@com.google.gwt.sample.contacts.client.Notification::hide()();
                $wnd.onmousemove = null;
            }
        }-*/;
    }
    

    【讨论】:

    • 我同意它应该很容易推出你自己的。值得注意的是,上面链接的那个似乎没有使用计时器来关闭通知。相反,它似乎在监听 onMouseMove 并在鼠标移动时立即开始解除。
    • 你是对的。使用隐藏鼠标移动通知的新版本更新帖子。
    猜你喜欢
    • 1970-01-01
    • 2020-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-03-15
    • 2011-09-10
    • 2011-01-19
    • 1970-01-01
    相关资源
    最近更新 更多