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