List of usage examples for com.google.gwt.user.client.ui MenuBar addCloseHandler
public HandlerRegistration addCloseHandler(CloseHandler<PopupPanel> handler)
From source file:com.ephesoft.gxt.core.client.ui.widget.CustomMenuBar.java
License:Open Source License
/** * Adds a menu item to the bar, that will open the specified menu when it is selected. * // ww w . java 2 s . com * @param text the item's text * @param asHTML <code>true</code> to treat the specified text as html * @param popup the menu to be cascaded from it * @return the {@link MenuItem} object created */ public MenuItem addItem(String text, boolean asHTML, MenuBar popup) { final Element parentElement = Document.get().createDivElement(); final Element element = Document.get().createDivElement(); element.setInnerHTML(text); parentElement.appendChild(element); final MenuItem addedItem = super.addItem(parentElement.getInnerHTML(), asHTML, popup); if (null != popup && null != addedItem) { popup.addCloseHandler(new CloseHandler<PopupPanel>() { @Override public void onClose(final CloseEvent<PopupPanel> event) { addedItem.removeStyleDependentName("selected"); } }); } return addedItem; }