Home

# Class goog.ui.Menu

A basic menu class.

extends goog.ui.Container

Instance Method Summary
| `addItem((goog.ui.MenuHeader|goog.ui.MenuItem|goog.ui.MenuSeparator|null) item)` Adds a new menu item at the end of the menu.
| `addItemAt((goog.ui.MenuHeader|goog.ui.MenuItem|goog.ui.MenuSeparator|null) item, number n)` Adds a new menu item at a specific index in the menu.
| `canHighlightItem(?goog.ui.Control item) ⇒ boolean` Returns whether the given item can be highlighted.
| `containsElement(?Element element) ⇒ boolean` Returns whether the provided element is to be considered inside the menu for purposes such as dismissing the menu on an event. This is so submenus can make use of elements outside their own DOM.
| `decorateContent(?Element element)` Decorate menu items located in any descendent node which as been explicitly marked as a 'content' node.
| `decorateInternal(?Element element)` Decorates the given element with this container. Overrides {@link goog.ui.Component#decorateInternal}. Considered protected.
| `getAllowAutoFocus() ⇒ boolean`
| `getAllowHighlightDisabled() ⇒ boolean`
| `getCssClass() ⇒ string` Returns the CSS class applied to menu elements, also used as the prefix for derived styles, if any. Subclasses should override this method as needed. Considered protected.
| `getItemAt(number n) ⇒ (goog.ui.MenuHeader|goog.ui.MenuItem|goog.ui.MenuSeparator|null)` Returns a reference to the menu item at a given index.
| `getItemCount() ⇒ number` Returns the number of items in the menu (including separators).
| `getItems() ⇒ ?Array` Returns an array containing the menu items contained in the menu.
| `getPosition() ⇒ ?goog.math.Coordinate` Gets the page offset of the menu, or null if the menu isn't visible
| `handleEnterItem(?goog.events.Event e) ⇒ boolean` Handles ENTER events raised by child controls when they are navigated to.
| `handleKeyEventInternal(?goog.events.KeyEvent e) ⇒ boolean` Attempts to handle a keyboard event; returns true if the event was handled, false otherwise. If the container is enabled, and a child is highlighted, calls the child control's {@code handleKeyEvent} method to give the control a chance to handle the event first.
| `highlightNextPrefix(string charStr) ⇒ boolean` Highlights the next item that begins with the specified string. If no (other) item begins with the given string, the selection is unchanged.
| `removeItem((goog.ui.MenuHeader|goog.ui.MenuItem|goog.ui.MenuSeparator|null) item)` Removes an item from the menu and disposes of it.
| `removeItemAt(number n)` Removes a menu item at a given index in the menu and disposes of it.
| `setAllowAutoFocus(boolean allow)` Sets whether the menu can automatically move focus to its key event target when it is set to visible.
| `setAllowHighlightDisabled(boolean allow)` Sets whether the menu will highlight disabled menu items or skip to the next active item.
| `setPosition((goog.math.Coordinate|null|number) x, number= opt_y)` Sets the position of the menu relative to the view port.
| `setVisible(boolean visible, boolean= opt_force) ⇒ boolean` Shows or hides the container. Does nothing if the container already has the requested visibility. Otherwise, dispatches a SHOW or HIDE event as appropriate, giving listeners a chance to prevent the visibility change.