Home

# Class goog.ui.SubMenu

Class representing a submenu that can be added as an item to other menus.

extends goog.ui.MenuItem

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.
| `clearTimers()` Clears the show and hide timers for the sub menu.
| `containsElement(?Element element) ⇒ boolean` Returns true if 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.
| `dismissSiblings_()` Dismiss all the sub menus of sibling menu items.
| `dismissSubMenu()` Dismisses the menu and all further submenus.
| `disposeInternal()` Disposes of the component. Calls {@code exitDocument}, which is expected to remove event handlers and clean up the component. Propagates the call to the component's children, if any. Removes the component's DOM from the document unless it was decorated.
| `enterDocument()` Configures the component after its DOM has been rendered, and sets up event handling. Overrides {@link goog.ui.Component#enterDocument}.
| `exitDocument()` Cleans up the component before its DOM is removed from the document, and removes event handlers. Overrides {@link goog.ui.Component#exitDocument} by making sure that components that are removed from the document aren't focusable (i.e. have no tab index).
| `getItemAt(number n) ⇒ ?goog.ui.Component` Returns a reference to the menu item at a given index.
| `getItemCount() ⇒ number` Returns the number of items in the sub menu (including separators).
| `getItems() ⇒ ?Array` Returns the menu items contained in the sub menu.
| `getMenu() ⇒ ?goog.ui.Menu` Gets a reference to the submenu's actual menu.
| `handleKeyEvent(?goog.events.KeyEvent e) ⇒ boolean` Handles a key event that is passed to the menu item from its parent because it is highlighted. If the right key is pressed the sub menu takes control and delegates further key events to its menu until it is dismissed OR the left key is pressed. TODO(user): RTL lookup
| `handleMouseOver(?goog.events.BrowserEvent e)` Handles mouseover events. Dispatches an ENTER event; if the event isn't canceled, the component is enabled, and it supports auto-highlighting, highlights the component. Considered protected; should only be used within this package and by subclasses.
| `isAlignedToEnd() ⇒ boolean` Determines whether the submenu is aligned at the end of the parent menu.
| `isPositionAdjustable() ⇒ boolean`
| `onChildHighlight_(?goog.events.Event e)` Listens to the sub menus items and ensures that this menu item is selected while dismissing the others. This handles the case when the user mouses over other items on their way to the sub menu.
| `onParentHidden_(?goog.events.Event e)` Listens to the parent menu's hide event and ensures that all submenus are hidden at the same time.
| `performActionInternal(?goog.events.BrowserEvent e) ⇒ boolean` Overrides the default mouseup event handler, so that the ACTION isn't dispatched for the submenu itself, instead the submenu is shown instantly.
| `positionSubMenu_()` Positions the submenu.
| `removeItem(?goog.ui.MenuItem item)` Removes an item from the menu and disposes it.
| `removeItemAt(number n)` Removes a menu item at a given index in the menu and disposes it.
| `setAlignToEnd(boolean alignToEnd)` Sets whether the submenu is aligned at the end of the parent menu.
| `setHighlighted(boolean highlight)` Highlights or unhighlights the component. Does nothing if this state transition is disallowed.
| `setMenu(?goog.ui.Menu menu, boolean= opt_internal)` Sets the submenu to a specific menu.
| `setMenuListenersEnabled_(?goog.ui.Menu menu, boolean attach)` Attaches or detaches menu event listeners to/from the given menu. Called each time a menu is attached to or detached from the submenu.
| `setPositionAdjustable(boolean isAdjustable)`
| `setSubMenuVisible_(boolean visible)` Sets the visiblility of the sub menu.
| `setVisible(boolean visible, boolean= opt_force) ⇒ boolean` Sets the menu item to be visible or invisible.
| `showSubMenu()` Show the submenu and ensure that all siblings are hidden.