# Yahoo! UI Library

### Menu 2.5.1

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

Show Private Show Protected

## `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

#### 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`

#### getFocusedMenu

`YAHOO.widget.Menu getFocusedMenu ( )`
Returns a reference to the menu that currently has focus.

Returns: `YAHOO.widget.Menu`

#### getFocusedMenuItem

`YAHOO.widget.MenuItem getFocusedMenuItem ( )`
Returns a reference to the menu item that currently has focus.

Returns: `YAHOO.widget.MenuItem`

#### getMenu

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

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

Returns: `YAHOO.widget.Menu`

#### getMenuItem

`YAHOO.widget.MenuItem getMenuItem ( p_sId )`
Returns a menu item with the specified id.

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

Returns: `YAHOO.widget.MenuItem`

#### getMenuItemGroup

`Array getMenuItemGroup ( p_sId )`
Returns an array of menu item instances whose corresponding `<li>` elements are child nodes of the `<ul>` element with the specified id.

Parameters:
  `p_sId <String>` String specifying the id of the `<ul>` element representing the group of menu items to be retrieved.

Returns: `Array`

#### 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 a collection of all menus registered with the menu manger.

Returns: `Array`

#### getVisible

`Array getVisible ( )`
Returns a collection of all visible menus registered with the menu manger.

Returns: `Array`

#### hideVisible

`void hideVisible ( )`
Hides all visible, dynamically positioned menus (excluding instances of YAHOO.widget.MenuBar).

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 )`
"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.

Returns: `void`

#### onMenuBlur

`private void onMenuBlur ( p_sType , p_aArgs )`
"blur" 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.

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>` The menu that fired the event.

Returns: `void`

#### onMenuFocus

`private void onMenuFocus ( p_sType , p_aArgs )`
"focus" 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.

Returns: `void`

#### onMenuVisibleConfigChange

`private void onMenuVisibleConfigChange ( p_sType , p_aArgs )`
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.

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 © 2007 Yahoo! Inc. All rights reserved.