Class sap.ui.commons.MenuButtonModule: sap/ui/commons/MenuButton

extends Button

Common button control that opens a menu when clicked by the user. The control provides an API for configuring the docking position of the menu.

Deprecated API:Since version 1.38. Instead, use the sap.m.MenuButton control.

Constructor Summary
new sap.ui.commons.MenuButton(sId?, mSettings?)Constructor for a new MenuButton.
Event Summary
itemSelected(oControlEvent)Event that is fired when a menu item is selected by the user
press(oControlEvent)Fired when an item from the menu was selected.
Events borrowed from class sap.ui.core.Control
Method Summary
sap.ui.commons.MenuButton.extend(sClassName, oClassInfo?, FNMetaImpl?)Creates a new subclass of class sap.ui.commons.MenuButton with name sClassName and enriches it with the information contained in oClassInfo.
sap.ui.commons.MenuButton.getMetadata()Returns a metadata object for class sap.ui.commons.MenuButton.
attachItemSelected(oData?, fnFunction, oListener?)Attaches event handler fnFunction to the itemSelected event of this sap.ui.commons.MenuButton.
attachPress(oData?, fnFunction, oListener?)Attach event-handler fnFunction to the 'press' event of this sap.ui.commons.MenuButton.
destroyMenu()Destroys the menu in the aggregation named menu.
detachItemSelected(fnFunction, oListener)Detaches event handler fnFunction from the itemSelected event of this sap.ui.commons.MenuButton.
detachPress(fnFunction, oListener)Detach event-handler fnFunction from the 'press' event of this sap.ui.commons.MenuButton.
fireItemSelected(mArguments?)Fires event itemSelected to attached listeners.
firePress(mArguments?)Fire event press to attached listeners.
getDockButton()Gets current value of property dockButton.
getDockMenu()Gets current value of property dockMenu.
getMenu()Gets content of aggregation menu.
setDockButton(sDockButton)Sets a new value for property dockButton.
setDockMenu(sDockMenu)Sets a new value for property dockMenu.
setMenu(oMenu)Setter for the aggregated menu.
Constructor Detail
new sap.ui.commons.MenuButton(sId?, mSettings?)
Constructor for a new MenuButton.

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
    • menu : sap.ui.unified.Menu (default)
  • Events
    • itemSelected : fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject]

In addition, all settings applicable to the base type sap.ui.commons.Button 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
Deprecated:
Since version 1.38. Instead, use the sap.m.MenuButton control.
Event Detail
itemSelected(oControlEvent)
Event that is fired when a menu item is selected by the user
Parameters:
{sap.ui.base.Event}oControlEvent
{sap.ui.base.EventProvider}oControlEvent.getSource
{object}oControlEvent.getParameters
{string}oControlEvent.getParameters.itemId The ID of the selected item
{sap.ui.unified.MenuItemBase}oControlEvent.getParameters.item The selected item
press(oControlEvent)
Fired when an item from the menu was selected.
Parameters:
{sap.ui.base.Event}oControlEvent
{sap.ui.base.EventProvider}oControlEvent.getSource
{object}oControlEvent.getParameters
{string}oControlEvent.getParameters.itemId The id of the selected item
{sap.ui.commons.MenuItemBase}oControlEvent.getParameters.item The selected item
See:
sap.ui.commons.MenuButton#itemSelected
Method Detail
sap.ui.commons.MenuButton.extend(sClassName, oClassInfo?, FNMetaImpl?): function
Creates a new subclass of class sap.ui.commons.MenuButton 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.commons.Button.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.ui.commons.MenuButton.getMetadata(): sap.ui.base.Metadata
Returns a metadata object for class sap.ui.commons.MenuButton.
Returns:
{sap.ui.base.Metadata} Metadata object describing this class
attachItemSelected(oData?, fnFunction, oListener?): sap.ui.commons.MenuButton
Attaches event handler fnFunction to the itemSelected event of this sap.ui.commons.MenuButton.

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.ui.commons.MenuButton itself.

Event that is fired when a menu item is selected by the user

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.ui.commons.MenuButton itself
Returns:
{sap.ui.commons.MenuButton} Reference to this in order to allow method chaining
attachPress(oData?, fnFunction, oListener?): sap.ui.commons.MenuButton
Attach event-handler fnFunction to the 'press' event of this sap.ui.commons.MenuButton.

Event is fired when an item from the menu was selected.

Parameters:
{object}oData? The object, that should be passed along with the event-object when firing the event.
{function}fnFunction The function to call, when the event occurs. This function will be called on the oListener-instance (if present) or in a 'static way'.
{object}oListener? Object on which to call the given function. If empty, the global context (window) is used.
Returns:
{sap.ui.commons.MenuButton}this to allow method chaining
See:
sap.ui.commons.MenuButton#attachItemSelected
Destroys the menu in the aggregation named menu.
Returns:
{sap.ui.commons.MenuButton}this to allow method chaining
detachItemSelected(fnFunction, oListener): sap.ui.commons.MenuButton
Detaches event handler fnFunction from the itemSelected event of this sap.ui.commons.MenuButton.

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.ui.commons.MenuButton} Reference to this in order to allow method chaining
detachPress(fnFunction, oListener): sap.ui.commons.MenuButton
Detach event-handler fnFunction from the 'press' event of this sap.ui.commons.MenuButton.

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

Parameters:
{function}fnFunction The function to call, when the event occurs.
{object}oListener Object on which the given function had to be called.
Returns:
{sap.ui.commons.MenuButton}this to allow method chaining
See:
sap.ui.commons.MenuButton#detachItemSelected
fireItemSelected(mArguments?): sap.ui.commons.MenuButton
Fires event itemSelected to attached listeners.

Expects the following event parameters:

  • itemId of type stringThe ID of the selected item
  • item of type sap.ui.unified.MenuItemBaseThe selected item
Parameters:
{Map}mArguments? The arguments to pass along with the event
Returns:
{sap.ui.commons.MenuButton} Reference to this in order to allow method chaining
firePress(mArguments?): sap.ui.commons.MenuButton
Fire event press to attached listeners.
Parameters:
{Map}mArguments? the arguments to pass along with the event.
Returns:
{sap.ui.commons.MenuButton}this to allow method chaining
See:
sap.ui.commons.MenuButton#fireItemSelected
getDockButton(): string
Gets current value of property dockButton.

The position / edge (see sap.ui.core.Popup.Dock) of the button where the menu is docked. Default is 'begin bottom'.

Returns:
{string} Value of property dockButton
getDockMenu(): string
Gets current value of property dockMenu.

The position / edge (see sap.ui.core.Popup.Dock) of the menu which is docked to the button. Default is 'begin top'.

Returns:
{string} Value of property dockMenu
Gets content of aggregation menu.

Menu that shall be opened when the button is clicked

Returns:
{sap.ui.unified.Menu}
setDockButton(sDockButton): sap.ui.commons.MenuButton
Sets a new value for property dockButton.

The position / edge (see sap.ui.core.Popup.Dock) of the button where the menu is docked. Default is 'begin bottom'.

When called with a value of null or undefined, the default value of the property will be restored.

Parameters:
{string}sDockButton New value for property dockButton
Returns:
{sap.ui.commons.MenuButton} Reference to this in order to allow method chaining
setDockMenu(sDockMenu): sap.ui.commons.MenuButton
Sets a new value for property dockMenu.

The position / edge (see sap.ui.core.Popup.Dock) of the menu which is docked to the button. Default is 'begin top'.

When called with a value of null or undefined, the default value of the property will be restored.

Parameters:
{string}sDockMenu New value for property dockMenu
Returns:
{sap.ui.commons.MenuButton} Reference to this in order to allow method chaining
setMenu(oMenu): sap.ui.commons.MenuButton
Setter for the aggregated menu.
Parameters:
{sap.ui.unified.Menu}oMenu
Returns:
{sap.ui.commons.MenuButton}this to allow method chaining