Class sap.m.MenuButtonModule: sap/m/MenuButton

extends Control

The sap.m.MenuButton control enables the user to show a hierarchical menu.

Constructor Summary
new sap.m.MenuButton(sId?, mSettings?)Constructor for a new MenuButton.
Event Summary
defaultAction(oControlEvent)Fired when the buttonMode is set to Split and the user presses the main button unless useDefaultActionOnly is set to false and another action from the menu has been selected previously.
Events borrowed from class sap.ui.core.Control
Method Summary
sap.m.MenuButton.extend(sClassName, oClassInfo?, FNMetaImpl?)Creates a new subclass of class sap.m.MenuButton with name sClassName and enriches it with the information contained in oClassInfo.
sap.m.MenuButton.getMetadata()Returns a metadata object for class sap.m.MenuButton.
attachDefaultAction(oData?, fnFunction, oListener?)Attaches event handler fnFunction to the defaultAction event of this sap.m.MenuButton.
bindMenu(oBindingInfo)Binds aggregation menu to model data.
destroyMenu()Destroys the menu in the aggregation menu.
detachDefaultAction(fnFunction, oListener)Detaches event handler fnFunction from the defaultAction event of this sap.m.MenuButton.
fireDefaultAction(mArguments?)Fires event defaultAction to attached listeners.
getActiveIcon()Gets current value of property activeIcon.
getButtonMode()Gets current value of property buttonMode.
getEnabled()Gets current value of property enabled.
getIcon()Gets current value of property icon.
getIconDensityAware()Gets current value of property iconDensityAware.
getMenu()Gets content of aggregation menu.
getText()Gets current value of property text.
getTextDirection()Gets current value of property textDirection.
getType()Gets current value of property type.
getUseDefaultActionOnly()Gets current value of property useDefaultActionOnly.
getWidth()Gets current value of property width.
init()Initializes the control.
setActiveIcon(sActiveIcon)Sets a new value for property activeIcon.
setButtonMode(sMode)Sets the buttonМode of the control.
setEnabled(bEnabled)Sets a new value for property enabled.
setIconDensityAware(bIconDensityAware)Sets a new value for property iconDensityAware.
setMenu(oMenu)Sets the aggregated menu.
setTextDirection(sTextDirection)Sets a new value for property textDirection.
setTooltip(vTooltip)Sets the tooltip for the MenuButton.
setUseDefaultActionOnly(sUseDefaultActionOnly)Sets a new value for property useDefaultActionOnly.
setWidth(sWidth)Sets a new value for property width.
unbindMenu()Unbinds aggregation menu from model data.
Constructor Detail
new sap.m.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:

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
defaultAction(oControlEvent)
Fired when the buttonMode is set to Split and the user presses the main button unless useDefaultActionOnly is set to false and another action from the menu has been selected previously.
Parameters:
{sap.ui.base.Event}oControlEvent
{sap.ui.base.EventProvider}oControlEvent.getSource
{object}oControlEvent.getParameters
Method Detail
sap.m.MenuButton.extend(sClassName, oClassInfo?, FNMetaImpl?): function
Creates a new subclass of class sap.m.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.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.MenuButton.getMetadata(): sap.ui.base.Metadata
Returns a metadata object for class sap.m.MenuButton.
Returns:
{sap.ui.base.Metadata} Metadata object describing this class
attachDefaultAction(oData?, fnFunction, oListener?): sap.m.MenuButton
Attaches event handler fnFunction to the defaultAction event of this sap.m.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.m.MenuButton itself.

Fired when the buttonMode is set to Split and the user presses the main button unless useDefaultActionOnly is set to false and another action from the menu has been selected previously.

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.MenuButton itself
Returns:
{sap.m.MenuButton} Reference to this in order to allow method chaining
bindMenu(oBindingInfo): sap.m.MenuButton
Binds aggregation menu 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.MenuButton} Reference to this in order to allow method chaining
destroyMenu(): sap.m.MenuButton
Destroys the menu in the aggregation menu.
Returns:
{sap.m.MenuButton} Reference to this in order to allow method chaining
detachDefaultAction(fnFunction, oListener): sap.m.MenuButton
Detaches event handler fnFunction from the defaultAction event of this sap.m.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.m.MenuButton} Reference to this in order to allow method chaining
fireDefaultAction(mArguments?): sap.m.MenuButton
Fires event defaultAction to attached listeners.
Parameters:
{Map}mArguments? The arguments to pass along with the event
Returns:
{sap.m.MenuButton} Reference to this in order to allow method chaining
getActiveIcon(): sap.ui.core.URI
Gets current value of property activeIcon.

The source property of an alternative icon for the active (pressed) state of the button. Both active and default icon properties should be defined and of the same type - image or icon font. If the icon property is not set or has a different type, the active icon is not displayed.

Returns:
{sap.ui.core.URI} Value of property activeIcon
getButtonMode(): sap.m.MenuButtonMode
Gets current value of property buttonMode.

Defines whether the MenuButton is set to Regular or Split mode.

Default value is Regular.

Returns:
{sap.m.MenuButtonMode} Value of property buttonMode
getEnabled(): boolean
Gets current value of property enabled.

Boolean property to enable the control (default is true).
Note: Depending on custom settings, the buttons that are disabled have other colors than the enabled ones.

Default value is true.

Returns:
{boolean} Value of property enabled
getIcon(): sap.ui.core.URI
Gets current value of property icon.

Defines the icon to be displayed as a graphical element within the button. It can be an image or an icon from the icon font.

Returns:
{sap.ui.core.URI} Value of property icon
getIconDensityAware(): boolean
Gets current value of property iconDensityAware.

When set to true (default), one or more requests are sent trying to get the density perfect version of image if this version of image doesn't exist on the server. If only one version of image is provided, set this value to false to avoid the attempt of fetching density perfect image.

Default value is true.

Returns:
{boolean} Value of property iconDensityAware
getMenu(): sap.m.Menu
Gets content of aggregation menu.

Defines the menu that opens for this button.

Returns:
{sap.m.Menu}
getText(): string
Gets current value of property text.

Defines the text of the MenuButton.
Note: In SplitbuttonMode with useDefaultActionOnly set to false, the text is changed to display the last selected item's text, while in RegularbuttonMode the text stays unchanged.

Returns:
{string} Value of property text
getTextDirection(): sap.ui.core.TextDirection
Gets current value of property textDirection.

Specifies the element's text directionality with enumerated options. By default, the control inherits text direction from the DOM.

Default value is Inherit.

Returns:
{sap.ui.core.TextDirection} Value of property textDirection
getType(): sap.m.ButtonType
Gets current value of property type.

Defines the type of the MenuButton (for example, Default, Accept, Reject, Back, etc.)

Default value is Default.

Returns:
{sap.m.ButtonType} Value of property type
getUseDefaultActionOnly(): Boolean
Gets current value of property useDefaultActionOnly.

Controls whether the default action handler is invoked always or it is invoked only until a menu item is selected. Usable only if buttonMode is set to Split.

Default value is false.

Returns:
{Boolean} Value of property useDefaultActionOnly
getWidth(): sap.ui.core.CSSSize
Gets current value of property width.

Defines the width of the MenuButton.

Returns:
{sap.ui.core.CSSSize} Value of property width
init()
Initializes the control.
setActiveIcon(sActiveIcon): sap.m.MenuButton
Sets a new value for property activeIcon.

The source property of an alternative icon for the active (pressed) state of the button. Both active and default icon properties should be defined and of the same type - image or icon font. If the icon property is not set or has a different type, the active icon is not displayed.

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

Parameters:
{sap.ui.core.URI}sActiveIcon New value for property activeIcon
Returns:
{sap.m.MenuButton} Reference to this in order to allow method chaining
setButtonMode(sMode): MenuButton
Sets the buttonМode of the control.
Parameters:
{sap.m.MenuButtonMode}sMode The new button mode
Returns:
{MenuButton} This instance
setEnabled(bEnabled): sap.m.MenuButton
Sets a new value for property enabled.

Boolean property to enable the control (default is true).
Note: Depending on custom settings, the buttons that are disabled have other colors than the enabled ones.

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

Default value is true.

Parameters:
{boolean}bEnabled New value for property enabled
Returns:
{sap.m.MenuButton} Reference to this in order to allow method chaining
setIconDensityAware(bIconDensityAware): sap.m.MenuButton
Sets a new value for property iconDensityAware.

When set to true (default), one or more requests are sent trying to get the density perfect version of image if this version of image doesn't exist on the server. If only one version of image is provided, set this value to false to avoid the attempt of fetching density perfect image.

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

Default value is true.

Parameters:
{boolean}bIconDensityAware New value for property iconDensityAware
Returns:
{sap.m.MenuButton} Reference to this in order to allow method chaining
setMenu(oMenu): sap.m.MenuButton
Sets the aggregated menu.
Parameters:
{sap.m.Menu}oMenu The menu to set
Returns:
{sap.m.MenuButton} Reference to this in order to allow method chaining
setTextDirection(sTextDirection): sap.m.MenuButton
Sets a new value for property textDirection.

Specifies the element's text directionality with enumerated options. By default, the control inherits text direction from the DOM.

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

Default value is Inherit.

Parameters:
{sap.ui.core.TextDirection}sTextDirection New value for property textDirection
Returns:
{sap.m.MenuButton} Reference to this in order to allow method chaining
setTooltip(vTooltip): *
Sets the tooltip for the MenuButton. Can either be an instance of a TooltipBase subclass or a simple string.
Parameters:
{sap.ui.core.TooltipBase}vTooltip The tooltip that should be shown.
Returns:
{*} this instance
setUseDefaultActionOnly(sUseDefaultActionOnly): sap.m.MenuButton
Sets a new value for property useDefaultActionOnly.

Controls whether the default action handler is invoked always or it is invoked only until a menu item is selected. Usable only if buttonMode is set to Split.

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

Default value is false.

Parameters:
{Boolean}sUseDefaultActionOnly New value for property useDefaultActionOnly
Returns:
{sap.m.MenuButton} Reference to this in order to allow method chaining
setWidth(sWidth): sap.m.MenuButton
Sets a new value for property width.

Defines the width of the MenuButton.

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

Parameters:
{sap.ui.core.CSSSize}sWidth New value for property width
Returns:
{sap.m.MenuButton} Reference to this in order to allow method chaining
unbindMenu(): sap.m.MenuButton
Unbinds aggregation menu from model data.
Returns:
{sap.m.MenuButton} Reference to this in order to allow method chaining