Closing a popup Panel by clicking a button in its child panel

1.5k views Asked by At

I have the following Panel hierarchy:

Custom Panel 1 contains PopupPanel contains DecklayoutPanel contains CustomPanel 2 contains FlowPanel contains Button.

How do i close the Custom Panel 1 or PopupPanel by clicking the button?

1

There are 1 answers

0
dting On

// CustomPanel2

class CustomPanel2 {
  @UiField Button closeButton;

  public CustomPanel2() {
    initWidget(uiBinder.createAndBindUi(this));
  }

  public HasClickHandlers closeButton() {
    return closeButton;
  }
}

// CustomPanel1

class CustomPanel1 implements ClickHandler {
  @UiField PopupPanel myPopupPanel;
  @UiField CustomPanel2 customPanel2;

  public CustomPanel1() {
    initWidget(uiBinder.createAndBindUi(this));
    customPanel2.closeButton().addClickHandler(this);
  }

  @Override
  public void onClick(ClickEvent e) {
    myPopupPanel.hide();
  }
}