我有以下Panel层次结构:
自定义面板1 包含 PopupPanel 包含 DecklayoutPanel 包含 CustomPanel 2 包含 FlowPanel 包含按钮。
如何通过单击按钮关闭自定义面板1或PopupPanel?
答案 0 :(得分:1)
// 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();
}
}