0
我有以下的小部件類,它包含一個煎茶TEXT按鈕點擊時應該顯示的菜單:菜單在TEXT按鈕無法正常工作
public class MyWidget extends Container {
public interface MyWidgetActionHandler {
void onClone();
}
private final MyData data;
private final MyWidgetActionHandler handler;
private TextButton menuButton;
public MyWidget(MyData data, MyWidgetActionHandler handler) {
this.data = data;
this.handler = handler;
setup();
}
private void setup() {
VerticalLayoutContainer mainContainer = new VerticalLayoutContainer();
Label dateLabel = new Label(DATE_TIME_FORMAT.format(new Date(data.getApplicability())));
mainContainer.add(dateLabel);
menuButton = new TextButton("...");
Menu menu = new Menu();
menu.add(new MenuItem("Clone...", new SelectionHandler<MenuItem>() {
@Override
public void onSelection(SelectionEvent<MenuItem> event) {
handler.onClone();
}
}));
menuButton.setMenu(menu);
mainContainer.add(menuButton);
setElement((Element) mainContainer.getElement());
DragSource dragSource = new DragSource(this) {
@Override
protected void onDragStart(DndDragStartEvent event) {
event.setData(data);
}
};
}
}
單擊該按鈕時,不顯示菜單。
任何幫助,將不勝感激。