简体   繁体   中英

Events on PopupPanel

I have a PopupPanel and am trying to do something whenever it is mouse clicked. For this, I have created a ClickHandler as follows:

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

and then add my handler to the panel as follows:

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

My event handler never gets called. Ideas?

Try to do

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM