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.
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(mParameters?)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 buttonMode of the control.
setEnabled(bEnabled)Sets a new value for property enabled.
setIcon(sIcon)Sets a new value for property icon.
setIconDensityAware(bIconDensityAware)Sets a new value for property iconDensityAware.
setMenu(oMenu)Sets the aggregated menu.
setText(sText)Sets a new value for property text.
setTextDirection(sTextDirection)Sets a new value for property textDirection.
setTooltip(vTooltip)Sets the tooltip for the MenuButton.
setType(sType)Sets a new value for property type.
setUseDefaultActionOnly(bUseDefaultActionOnly)Sets a new value for property useDefaultActionOnly.
setWidth(sWidth)Sets a new value for property width.
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:
stringsId?ID for the new control, generated automatically if no ID is given
objectmSettings?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.EventoControlEvent
sap.ui.base.EventProvideroControlEvent.getSource
objectoControlEvent.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:
stringsClassNameName of the class being created
objectoClassInfo?Object literal with information about the class
functionFNMetaImpl?Constructor function for the metadata object; if not given, it defaults to sap.ui.core.ElementMetadata
Returns:
functionCreated class / constructor function
sap.m.MenuButton.getMetadata(): sap.ui.base.Metadata
Returns a metadata object for class sap.m.MenuButton.
Returns:
sap.ui.base.MetadataMetadata 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:
objectoData?An application-specific payload object that will be passed to the event handler along with the event object when firing the event
functionfnFunctionThe function to be called when the event occurs
objectoListener?Context object to call the event handler with. Defaults to this sap.m.MenuButton itself
Returns:
sap.m.MenuButtonReference to this in order to allow method chaining
destroyMenu(): sap.m.MenuButton
Destroys the menu in the aggregation menu.
Returns:
sap.m.MenuButtonReference 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:
functionfnFunctionThe function to be called, when the event occurs
objectoListenerContext object on which the given function had to be called
Returns:
sap.m.MenuButtonReference to this in order to allow method chaining
fireDefaultAction(mParameters?): sap.m.MenuButton
Fires event defaultAction to attached listeners.
Parameters:
objectmParameters?Parameters to pass along with the event
Returns:
sap.m.MenuButtonReference 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.URIValue 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.MenuButtonModeValue 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:
booleanValue 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.URIValue 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:
booleanValue 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:
stringValue 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.TextDirectionValue 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.ButtonTypeValue 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:
booleanValue of property useDefaultActionOnly
getWidth(): sap.ui.core.CSSSize

Gets current value of property width.

Defines the width of the MenuButton.
Note:As per visual design this width can be maximum of 12rem (192px).

Returns:
sap.ui.core.CSSSizeValue 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.URIsActiveIconNew value for property activeIcon
Returns:
sap.m.MenuButtonReference to this in order to allow method chaining
setButtonMode(sMode): sap.m.MenuButton
Sets the buttonMode of the control.
Parameters:
sap.m.MenuButtonModesModeThe new button mode
Returns:
sap.m.MenuButtonThis 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:
booleanbEnabledNew value for property enabled
Returns:
sap.m.MenuButtonReference to this in order to allow method chaining
setIcon(sIcon): sap.m.MenuButton

Sets a new value for 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.

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

Parameters:
sap.ui.core.URIsIconNew value for property icon
Returns:
sap.m.MenuButtonReference 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:
booleanbIconDensityAwareNew value for property iconDensityAware
Returns:
sap.m.MenuButtonReference to this in order to allow method chaining
setMenu(oMenu): sap.m.MenuButton
Sets the aggregated menu.
Parameters:
sap.m.MenuoMenuThe menu to set
Returns:
sap.m.MenuButtonReference to this in order to allow method chaining
setText(sText): sap.m.MenuButton

Sets a new value for 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.

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

Parameters:
stringsTextNew value for property text
Returns:
sap.m.MenuButtonReference 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.TextDirectionsTextDirectionNew value for property textDirection
Returns:
sap.m.MenuButtonReference 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.TooltipBasevTooltipThe tooltip that should be shown.
Returns:
*this instance
setType(sType): sap.m.MenuButton

Sets a new value for property type.

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

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

Default value is Default.

Parameters:
sap.m.ButtonTypesTypeNew value for property type
Returns:
sap.m.MenuButtonReference to this in order to allow method chaining
setUseDefaultActionOnly(bUseDefaultActionOnly): 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:
booleanbUseDefaultActionOnlyNew value for property useDefaultActionOnly
Returns:
sap.m.MenuButtonReference 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.
Note:As per visual design this width can be maximum of 12rem (192px).

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

Parameters:
sap.ui.core.CSSSizesWidthNew value for property width
Returns:
sap.m.MenuButtonReference to this in order to allow method chaining