PopupPanel上的事件

时间:2012-01-31 11:02:43

标签: java gwt

我有一个PopupPanel,并且只要点击鼠标就会尝试做某事。为此,我创建了一个ClickHandler,如下所示:

ClickHandler handler = new ClickHandler() {
   @Override
   public void onClick(ClickEvent event) {
     System.out.println("I have been clicked...");
   }
};

然后将我的处理程序添加到面板中,如下所示:

PopupPanel panel = new PopupPanel();
// assign values to panel...
panel.addHandler(handler, ClickEvent.getType());

我的事件处理程序永远不会被调用。想法?

1 个答案:

答案 0 :(得分:3)

尝试

    panel.sinkEvents(Event.ONCLICK); 
    panel.addHandler(handler, ClickEvent.getType());