Now, with a dynamic context (defined by View).
The only problem that remains is that when I click the context menu,
the place changes but popup still keeps opened.
Does someone knows how to solve it?
public class TextCellNX extends AbstractSafeHtmlCell<String>{
MenuItem[] contextMenu;
public TextCellNX(MenuItem[] contextMenu) {
super(SimpleSafeHtmlRenderer.getInstance(), "contextmenu");
this.contextMenu = contextMenu;
}
public TextCellNX(SafeHtmlRenderer<String> renderer) {
super(renderer);
}
@Override
public void render(Context context, SafeHtml value, SafeHtmlBuilder
sb) {
if (value != null) {
sb.append(value);
}
}
@Override
public void onBrowserEvent(Context context, Element parent, String
value, NativeEvent event, ValueUpdater<String> valueUpdater) {
if ("contextmenu".equals(event.getType())) {
event.preventDefault();
event.stopPropagation();
MenuItem acao = contextMenu[0];
MenuBar popupMenuBar = new MenuBar(true);
popupMenuBar.addItem(acao);
popupMenuBar.setVisible(true);
PopupPanel popupPanel = new PopupPanel(true);
popupPanel.add(popupMenuBar);
popupPanel.setPopupPosition(event.getClientX(),
event.getClientY());
popupPanel.show();
}
}
}
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.