Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在弹出窗口外处理单击事件_Java_Javascript_Gwt - Fatal编程技术网

Java 在弹出窗口外处理单击事件

Java 在弹出窗口外处理单击事件,java,javascript,gwt,Java,Javascript,Gwt,你会如何处理“弹出窗口”之外的点击事件,我实际上是在使用用于GWT的LinkedIn跳房子包装器。其想法是,当用户在弹出窗口外单击时(即在.hopsocch bubble container)弹出窗口应隐藏。调用gwtour.endTour(false)最终导致弹出窗口隐藏。这很好,但是,我还需要在“dashboardLink”菜单项也被单击时进行修改;也不应调用此$(“html”).bind(“单击”,…)。它叫什么,不知道为什么 代码: private void bindHandlers()

你会如何处理“弹出窗口”之外的点击事件,我实际上是在使用用于GWT的LinkedIn跳房子包装器。其想法是,当用户在弹出窗口外单击时(即在
.hopsocch bubble container
)弹出窗口应隐藏。调用
gwtour.endTour(false)最终导致弹出窗口隐藏。这很好,但是,我还需要在“dashboardLink”菜单项也被单击时进行修改;也不应调用此$(“html”).bind(“单击”,…)。它叫什么,不知道为什么

代码:

private void bindHandlers(){

    // Handle when click event came from here
    $(".hopscotch-bubble-container").bind("click", new com.google.gwt.query.client.Function() {
        @Override
        public boolean f(com.google.gwt.user.client.Event e) {
            e.stopPropagation();
            return false;
        }
    });
    $("#dashboardLink").bind("click", new com.google.gwt.query.client.Function() {
        @Override
        public boolean f(com.google.gwt.user.client.Event e) {
            e.stopPropagation();
            return false;
        }
    });
    // This event handler closes the GWT Tour
    // when user click outside of it
    $("html").bind("click", new com.google.gwt.query.client.Function() {
        @Override
        public boolean f(com.google.gwt.user.client.Event e) {
            GwtTour.endTour(false);
            return true;
        }
    });
}

检查click事件的来源,如果它是从预期来源触发的,则执行所需操作

如果菜单项是此单击事件的来源,则不执行任何操作

看看:

$("html").bind("click", new com.google.gwt.query.client.Function() {
    @Override
    public boolean f(com.google.gwt.user.client.Event e) {
        // you can check it using instanceof operator, object references or Element ID
        // e.getSource() instanceof MenuItem
        // ((Widget) e.getSource()).getElement().getId()
        if (e.getSource() != dashboardLink) {
            GwtTour.endTour(false);
            return true;
        } else {
            return false;
        }
    }
});

您能否将gwt中的DialogBox类与“new DialogBox(true)”一起用于自动隐藏选项?