# Yahoo! UI Library

### Menu Library

Yahoo! UI Library > menu > YAHOO.widget.MenuManager

## `static` Class YAHOO.widget.MenuManager

Singleton that manages a collection of all menus and menu items. Listens for DOM events at the document level and dispatches the events to the corresponding menu or menu item.

### Methods

#### addItem

`private void addItem ( p_oItem )`
Adds an item to the collection of known menu items.

Parameters:
  `p_oItem <YAHOO.widget.MenuItem>` Object specifying the MenuItem instance to be added.

Returns: `void`

#### addMenu

`void addMenu ( p_oMenu )`
Adds a menu to the collection of known menus.

Parameters:
  `p_oMenu <YAHOO.widget.Menu>` Object specifying the Menu instance to be added.

Returns: `void`

#### getMenu

`YAHOO.widget.Menu getMenu ( p_sId )`
Returns a menu with the specified id.

Parameters:
  `p_sId <String>` String specifying the id of the menu to be retrieved.

Returns: `YAHOO.widget.Menu`

#### getMenuRootElement

`private void getMenuRootElement ( p_oElement )`
Finds the root DIV node of a menu or the root LI node of a menu item.

Parameters:
  `p_oElement <HTMLElement>` Object specifying an HTML element.

Returns: `void`

#### getMenus

`Array getMenus ( )`
Returns an array of all menus registered with the menu manger.

Returns: `Array`

#### hideVisible

`void hideVisible ( )`
Hides all visible, dynamically positioned menus.

Returns: `void`

#### onDOMEvent

`private void onDOMEvent ( p_oEvent )`
Generic, global event handler for all of a menu's DOM-based events. This listens for events against the document object. If the target of a given event is a member of a menu or menu item's DOM, the instance's corresponding Custom Event is fired.

Parameters:
  `p_oEvent <Event>` Object representing the DOM event object passed back by the event utility (YAHOO.util.Event).

Returns: `void`

#### onItemAdded

`private void onItemAdded ( p_sType , p_aArgs )`
"itemadded" event handler for a Menu instance.

Parameters:
  `p_sType <String>` String representing the name of the event that was fired.
  `p_aArgs <Array>` Array of arguments sent when the event was fired.

Returns: `void`

#### onItemDestroy

`private void onItemDestroy ( p_sType , p_aArgs , p_oItem )`
"destroy" event handler for a MenuItem instance.

Parameters:
  `p_sType <String>` String representing the name of the event that was fired.
  `p_aArgs <Array>` Array of arguments sent when the event was fired.
  `p_oItem <YAHOO.widget.MenuItem>` Object representing the menu item that fired the event.

Returns: `void`

#### onItemRemoved

`private void onItemRemoved ( p_sType , p_aArgs )`
"itemremoved" event handler for a Menu instance.

Parameters:
  `p_sType <String>` String representing the name of the event that was fired.
  `p_aArgs <Array>` Array of arguments sent when the event was fired.

Returns: `void`

#### onMenuDestroy

`private void onMenuDestroy ( p_sType , p_aArgs , p_oMenu )`
"destroy" event handler for a menu.

Parameters:
  `p_sType <String>` String representing the name of the event that was fired.
  `p_aArgs <Array>` Array of arguments sent when the event was fired.
  `p_oMenu <YAHOO.widget.Menu>` Object representing the menu that fired the event.

Returns: `void`

#### onMenuVisibleConfigChange

`private void onMenuVisibleConfigChange ( p_sType , p_aArgs , p_oMenu )`
Event handler for when the "visible" configuration property of a Menu instance changes.

Parameters:
  `p_sType <String>` String representing the name of the event that was fired.
  `p_aArgs <Array>` Array of arguments sent when the event was fired.
  `p_oMenu <YAHOO.widget.Menu>` Object representing the menu that fired the event.

Returns: `void`

#### removeItem

`private void removeItem ( p_oItem )`
Removes an item from the collection of known menu items.

Parameters:
  `p_oItem <YAHOO.widget.MenuItem>` Object specifying the MenuItem instance to be removed.

Returns: `void`

#### removeMenu

`void removeMenu ( p_oMenu )`
Removes a menu from the collection of known menus.

Parameters:
  `p_oMenu <YAHOO.widget.Menu>` Object specifying the Menu instance to be removed.

Returns: `void`

#### toString

`String toString ( )`
Returns a string representing the menu manager.

Returns: `String`

Copyright © 2006 Yahoo! Inc. All rights reserved.