Class sap.m.MenuModule: sap/m/Menu

extends Control

The sap.m.Menu control represents a hierarchical menu. When opened on mobile devices it occupies the whole screen.

Constructor Summary
new sap.m.Menu(sId?, mSettings?)Constructor for a new Menu.
Event Summary
closed(oControlEvent)Fired when the menu is closed.
itemSelected(oControlEvent)Fired when a MenuItem is selected.
Events borrowed from class sap.ui.core.Control
Method Summary
sap.m.Menu.extend(sClassName, oClassInfo?, FNMetaImpl?)Creates a new subclass of class sap.m.Menu with name sClassName and enriches it with the information contained in oClassInfo.
sap.m.Menu.getMetadata()Returns a metadata object for class sap.m.Menu.
addItem(oItem)Adds some item to the aggregation items.
attachClosed(oData?, fnFunction, oListener?)Attaches event handler fnFunction to the closed event of this sap.m.Menu.
attachItemSelected(oData?, fnFunction, oListener?)Attaches event handler fnFunction to the itemSelected event of this sap.m.Menu.
bindItems(oBindingInfo)Binds aggregation items to model data.
close()Closes the Menu.
destroyItems()Destroys all the items in the aggregation items.
detachClosed(fnFunction, oListener)Detaches event handler fnFunction from the closed event of this sap.m.Menu.
detachItemSelected(fnFunction, oListener)Detaches event handler fnFunction from the itemSelected event of this sap.m.Menu.
fireClosed(mArguments?)Fires event closed to attached listeners.
fireItemSelected(mArguments?)Fires event itemSelected to attached listeners.
getItems()Gets content of aggregation items.
getTitle()Gets current value of property title.
indexOfItem(oItem)Checks for the provided sap.m.MenuItem in the aggregation items.
init()Initializes the control.
insertItem(oItem, iIndex)Inserts a item into the aggregation items.
openBy(oControl, bWithKeyboard)Opens the Menu next to the given control.
removeAllItems()Removes all the controls from the aggregation items.
removeItem(vItem)Removes a item from the aggregation items.
setTitle(sTitle)Sets the title of the Menu.
unbindItems()Unbinds aggregation items from model data.
Constructor Detail
new sap.m.Menu(sId?, mSettings?)
Constructor for a new Menu.

Accepts an object literal mSettings that defines initial property values, aggregated and associated objects as well as event handlers. See sap.ui.base.ManagedObject for a general description of the syntax of the settings object.

The supported settings are:

  • Properties
  • Aggregations
    • items : sap.m.MenuItem[] (default)
  • Events
    • itemSelected : fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject]
    • closed : fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject]

In addition, all settings applicable to the base type sap.ui.core.Control can be used as well.

Parameters:
{string}sId? ID for the new control, generated automatically if no ID is given
{object}mSettings? Initial settings for the new control
Event Detail
closed(oControlEvent)
Fired when the menu is closed.
Parameters:
{sap.ui.base.Event}oControlEvent
{sap.ui.base.EventProvider}oControlEvent.getSource
{object}oControlEvent.getParameters
itemSelected(oControlEvent)
Fired when a MenuItem is selected.
Parameters:
{sap.ui.base.Event}oControlEvent
{sap.ui.base.EventProvider}oControlEvent.getSource
{object}oControlEvent.getParameters
{sap.m.MenuItem}oControlEvent.getParameters.item The MenuItem which was selected.
Method Detail
sap.m.Menu.extend(sClassName, oClassInfo?, FNMetaImpl?): function
Creates a new subclass of class sap.m.Menu with name sClassName and enriches it with the information contained in oClassInfo.

oClassInfo might contain the same kind of information as described in sap.ui.core.Control.extend.

Parameters:
{string}sClassName Name of the class being created
{object}oClassInfo? Object literal with information about the class
{function}FNMetaImpl? Constructor function for the metadata object; if not given, it defaults to sap.ui.core.ElementMetadata
Returns:
{function} Created class / constructor function
sap.m.Menu.getMetadata(): sap.ui.base.Metadata
Returns a metadata object for class sap.m.Menu.
Returns:
{sap.ui.base.Metadata} Metadata object describing this class
addItem(oItem): sap.m.Menu
Adds some item to the aggregation items.
Parameters:
{sap.m.MenuItem}oItem the item to add; if empty, nothing is inserted
Returns:
{sap.m.Menu} Reference to this in order to allow method chaining
attachClosed(oData?, fnFunction, oListener?): sap.m.Menu
Attaches event handler fnFunction to the closed event of this sap.m.Menu.

When called, the context of the event handler (its this) will be bound to oListener if specified, otherwise it will be bound to this sap.m.Menu itself.

Fired when the menu is closed.

Parameters:
{object}oData? An application-specific payload object that will be passed to the event handler along with the event object when firing the event
{function}fnFunction The function to be called when the event occurs
{object}oListener? Context object to call the event handler with. Defaults to this sap.m.Menu itself
Returns:
{sap.m.Menu} Reference to this in order to allow method chaining
attachItemSelected(oData?, fnFunction, oListener?): sap.m.Menu
Attaches event handler fnFunction to the itemSelected event of this sap.m.Menu.

When called, the context of the event handler (its this) will be bound to oListener if specified, otherwise it will be bound to this sap.m.Menu itself.

Fired when a MenuItem is selected.

Parameters:
{object}oData? An application-specific payload object that will be passed to the event handler along with the event object when firing the event
{function}fnFunction The function to be called when the event occurs
{object}oListener? Context object to call the event handler with. Defaults to this sap.m.Menu itself
Returns:
{sap.m.Menu} Reference to this in order to allow method chaining
bindItems(oBindingInfo): sap.m.Menu
Binds aggregation items to model data.

See ManagedObject.bindAggregation for a detailed description of the possible properties of oBindingInfo.

Parameters:
{object}oBindingInfo The binding information
Returns:
{sap.m.Menu} Reference to this in order to allow method chaining
close()
Closes the Menu.
destroyItems(): sap.m.Menu
Destroys all the items in the aggregation items.
Returns:
{sap.m.Menu} Reference to this in order to allow method chaining
detachClosed(fnFunction, oListener): sap.m.Menu
Detaches event handler fnFunction from the closed event of this sap.m.Menu.

The passed function and listener object must match the ones used for event registration.

Parameters:
{function}fnFunction The function to be called, when the event occurs
{object}oListener Context object on which the given function had to be called
Returns:
{sap.m.Menu} Reference to this in order to allow method chaining
detachItemSelected(fnFunction, oListener): sap.m.Menu
Detaches event handler fnFunction from the itemSelected event of this sap.m.Menu.

The passed function and listener object must match the ones used for event registration.

Parameters:
{function}fnFunction The function to be called, when the event occurs
{object}oListener Context object on which the given function had to be called
Returns:
{sap.m.Menu} Reference to this in order to allow method chaining
fireClosed(mArguments?): sap.m.Menu
Fires event closed to attached listeners.
Parameters:
{Map}mArguments? The arguments to pass along with the event
Returns:
{sap.m.Menu} Reference to this in order to allow method chaining
fireItemSelected(mArguments?): sap.m.Menu
Fires event itemSelected to attached listeners.

Expects the following event parameters:

  • item of type sap.m.MenuItemThe MenuItem which was selected.
Parameters:
{Map}mArguments? The arguments to pass along with the event
Returns:
{sap.m.Menu} Reference to this in order to allow method chaining
getItems(): sap.m.MenuItem[]
Gets content of aggregation items.

Defines the items contained within this control.

Returns:
{sap.m.MenuItem[]}
getTitle(): string
Gets current value of property title.

Defines the Menu title.

Returns:
{string} Value of property title
indexOfItem(oItem): int
Checks for the provided sap.m.MenuItem in the aggregation items. and returns its index if found or -1 otherwise.
Parameters:
{sap.m.MenuItem}oItem The item whose index is looked for
Returns:
{int} The index of the provided control in the aggregation if found, or -1 otherwise
init()
Initializes the control.
insertItem(oItem, iIndex): sap.m.Menu
Inserts a item into the aggregation items.
Parameters:
{sap.m.MenuItem}oItem the item to insert; if empty, nothing is inserted
{int}iIndex the 0-based index the item should be inserted at; for a negative value of iIndex, the item is inserted at position 0; for a value greater than the current size of the aggregation, the item is inserted at the last position
Returns:
{sap.m.Menu} Reference to this in order to allow method chaining
openBy(oControl, bWithKeyboard)
Opens the Menu next to the given control.
Parameters:
oControl The control that defines the position for the menu
bWithKeyboard Whether the menu is opened with a shortcut or not
removeAllItems(): sap.m.MenuItem[]
Removes all the controls from the aggregation items.

Additionally, it unregisters them from the hosting UIArea.

Returns:
{sap.m.MenuItem[]} An array of the removed elements (might be empty)
removeItem(vItem): sap.m.MenuItem
Removes a item from the aggregation items.
Parameters:
{int|string|sap.m.MenuItem}vItem The itemto remove or its index or id
Returns:
{sap.m.MenuItem} The removed item or null
setTitle(sTitle)
Sets the title of the Menu.
Parameters:
{String}sTitle The new title of the Menu
unbindItems(): sap.m.Menu
Unbinds aggregation items from model data.
Returns:
{sap.m.Menu} Reference to this in order to allow method chaining