Java – add the click handler to the horizontalpanel in GWT

How to add a click handler to the horizontalpanel?

It uses adddomhandler () in the newer version of GWT, but I had to downgrade to unsupported GWT 2.0 4. I have done this before:

horizontalPanel.getWidget(1).addDomHandler(someClickHandler,ClickEvent.getType());
//or
horizontalPanel.addDomHandler(someClickHandler,ClickEvent.getType());

Solution

Use focuspanels instead of hooking native events To capture the number of clicks for the entire panel:

FocusPanel wrapper = new FocusPanel();
HorizontalPanel panel = new HorizontalPanel();
wrapper.add(panel);
wrapper.addClickHandler(new ClickHandler() {
  @Override
  public void onClick(ClickEvent event) {
    // Handle the click
  }
});

// Add wrapper to the parent widget that prevIoUsly held panel.

Or capture the clicks in the cell in the horizontalpanel:

IsWidget child; // Any widget
HorizontalPanel panel = new HorizontalPanel();
FocusPanel click@R_630_2419@ = new FocusPanel();

click@R_630_2419@.add(child);
panel.add(click@R_630_2419@);

click@R_630_2419@.addClickHandler(...);
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>