3
我是GWT新手! 任何人都可以幫助我實現與GWT的上下文菜單? 我看過一些例子:如何使用本地GWT(Java)實現上下文菜單?
MenuBar options = new MenuBar(true);
MenuBar gwtPopup = new MenuBar(true);
options.addItem("GWT", gwtPopup);
MenuItem entryPoint = new MenuItem(new SafeHtmlBuilder().appendEscaped("EntryPoint").toSafeHtml());
entryPoint.setScheduledCommand(new ScheduledCommand()
{
public void execute()
{
Window.alert("hello");
}
});
final DialogBox menuWrapper = new DialogBox(true);
menuWrapper.add(options);
gwtPopup.addItem(entryPoint);
Button showMenu = new Button("Click me", new ClickHandler()
{
public void onClick(ClickEvent event)
{
menuWrapper.showRelativeTo(menuWrapper);
}
});
RootPanel.get().add(showMenu);
但它不起作用。謝謝。
你必須要更加具體。什麼不行?你期望它做什麼? –
它會很好,如果你定義哪個位不能在你的代碼中工作,其他的事情是嘗試使用PopupPanel來代替對話 – user902383
只是爲你寫博客:) http://codeinventions.blogspot.in/2014/07/context-菜單 - 或 - 右鍵單擊處理程序,in.html –