A menu is an interactive element which provides a choice of different actions to the user. These actions (items) can also be organized in submenus. Like other dialog-like controls, the menu is not rendered within the control hierarchy. Instead it can be opened at a specified position via a function call.
Since: 1.21.0.
Event Summary
itemSelect(oControlEvent)Fired on the root menu of a menu hierarchy whenever a user selects an item within the menu or within one of its direct or indirect submenus. Method Summary
sap.ui.unified.Menu.extend(sClassName, oClassInfo?, FNMetaImpl?)Creates a new subclass of class sap.ui.unified.Menu with name sClassName
and enriches it with the information contained in oClassInfo
. addAriaLabelledBy(vAriaLabelledBy)Adds some ariaLabelledBy into the association ariaLabelledBy
. addItem(oItem)Adds some item to the aggregation items
. attachItemSelect(oData?, fnFunction, oListener?)Attaches event handler fnFunction
to the itemSelect
event of this sap.ui.unified.Menu
. destroyItems()Destroys all the items in the aggregation items
. detachItemSelect(fnFunction, oListener)Detaches event handler fnFunction
from the itemSelect
event of this sap.ui.unified.Menu
. fireItemSelect(mArguments?)Fires event itemSelect
to attached listeners. getAriaLabelledBy()Returns array of IDs of the elements which are the current targets of the association ariaLabelledBy
. getEnabled()Gets current value of property enabled
. getItems()Gets content of aggregation items
. indexOfItem(oItem)Checks for the provided sap.ui.unified.MenuItemBase
in the aggregation items
. insertItem(oItem, iIndex)Inserts a item into the aggregation items
. open(bWithKeyboard, oOpenerRef, sMy, sAt, oOf, sOffset?, sCollision?)Opens the menu at the specified position. removeAriaLabelledBy(vAriaLabelledBy)Removes an ariaLabelledBy from the association named ariaLabelledBy
. removeItem(vItem)Removes a item from the aggregation items
. setEnabled(bEnabled)Sets a new value for property enabled
. setPageSize(iPageSize)Sets a new value for property pageSize
. addStyleClass,
allowTextSelection,
attachBrowserEvent,
attachValidateFieldGroup,
checkFieldGroupIds,
clone,
detachBrowserEvent,
detachValidateFieldGroup,
fireValidateFieldGroup,
getAccessibilityInfo,
getBusy,
getBusyIndicatorDelay,
getControlsByFieldGroupId,
getFieldGroupIds,
getIdForLabel,
getRenderer,
getVisible,
hasStyleClass,
isBusy,
placeAt,
removeStyleClass,
rerender,
setBusy,
setBusyIndicatorDelay,
setFieldGroupIds,
setVisible,
toggleStyleClass,
triggerValidateFieldGroup $,
addCustomData,
addDependent,
addEventDelegate,
applyFocusInfo,
bindElement,
data,
destroy,
destroyCustomData,
destroyDependents,
destroyLayoutData,
destroyTooltip,
enhanceAccessibilityState,
findElements,
fireEvent,
focus,
getCustomData,
getDependents,
getDomRef,
getElementBinding,
getFocusDomRef,
getFocusInfo,
getInterface,
getLayoutData,
getMetadata,
getTooltip,
getTooltip_AsString,
getTooltip_Text,
indexOfCustomData,
indexOfDependent,
init,
insertCustomData,
insertDependent,
prop,
removeAllCustomData,
removeAllDependents,
removeCustomData,
removeDependent,
removeEventDelegate,
setLayoutData,
setTooltip,
toString,
unbindElement addAggregation,
addAssociation,
applySettings,
attachFormatError,
attachModelContextChange,
attachParseError,
attachValidationError,
attachValidationSuccess,
bindAggregation,
bindContext,
bindObject,
bindProperty,
destroyAggregation,
detachFormatError,
detachModelContextChange,
detachParseError,
detachValidationError,
detachValidationSuccess,
findAggregatedObjects,
fireFormatError,
fireModelContextChange,
fireParseError,
fireValidationError,
fireValidationSuccess,
getAggregation,
getAssociation,
getBinding,
getBindingContext,
getBindingInfo,
getBindingPath,
getEventingParent,
getId,
getModel,
getObjectBinding,
getOriginInfo,
getParent,
getProperty,
hasModel,
indexOfAggregation,
insertAggregation,
isBound,
isInvalidateSuppressed,
isTreeBinding,
propagateMessages,
removeAggregation,
removeAllAggregation,
removeAllAssociation,
removeAssociation,
setAggregation,
setAssociation,
setBindingContext,
setModel,
setProperty,
unbindAggregation,
unbindContext,
unbindObject,
unbindProperty,
validateAggregation,
validateProperty Constructor Detail
new sap.ui.unified.Menu(sId?, mSettings?)
Constructor for a new Menu control.
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.ui.unified.MenuItemBase[] (default)
- Events
- itemSelect : 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
itemSelect(oControlEvent)
Fired on the root menu of a menu hierarchy whenever a user selects an item within the menu or within one of its direct or indirect submenus. Note: There is also a select event available for each single menu item. This event and the event of the menu items are redundant.
Parameters:
Method Detail
sap.ui.unified.Menu.extend(sClassName, oClassInfo?, FNMetaImpl?): function
Creates a new subclass of class sap.ui.unified.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 |
Returns a metadata object for class sap.ui.unified.Menu.
Returns:
Adds some ariaLabelledBy into the association ariaLabelledBy
.
Parameters:
{string|sap.ui.core.Control} | vAriaLabelledBy | the ariaLabelledBy to add; if empty, nothing is inserted |
- Since:
- 1.26.3
Returns:
Adds some item to the aggregation items
.
Parameters:
Returns:
Attaches event handler
fnFunction
to the
itemSelect
event of this
sap.ui.unified.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.ui.unified.Menu
itself.
Fired on the root menu of a menu hierarchy whenever a user selects an item within the menu or within one of its direct or indirect submenus. Note: There is also a select event available for each single menu item. This event and the event of the menu items are redundant.
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.unified.Menu itself |
Returns:
close(): void
Closes the menu.
Destroys all the items in the aggregation items
.
Returns:
Detaches event handler
fnFunction
from the
itemSelect
event of this
sap.ui.unified.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:
Fires event
itemSelect
to attached listeners.
Expects the following event parameters:
item
of type sap.ui.unified.MenuItemBase
The action (item) which was selected by the user.
Parameters:
{Map} | mArguments? | The arguments to pass along with the event |
Returns:
Returns array of IDs of the elements which are the current targets of the association ariaLabelledBy
.
- Since:
- 1.26.3
Returns:
getEnabled(): boolean
Gets current value of property
enabled
.
When a menu is disabled none of its items can be selected by the user. The enabled property of an item (@link sap.ui.unified.MenuItemBase#getEnabled) has no effect when the menu of the item is disabled.
Default value is true
.
Returns:
{boolean} | Value of property enabled |
Gets content of aggregation
items
.
The available actions to be displayed as items of the menu.
Returns:
getMaxVisibleItems(): int
Gets current value of property
maxVisibleItems
.
The maximum number of items which are displayed before an overflow mechanism takes effect. A value smaller than 1 means an infinite number of visible items. The overall height of the menu is limited by the height of the screen. If the maximum possible height is reached, an overflow takes effect, even if the maximum number of visible items is not yet reached.
Default value is 0
.
Returns:
{int} | Value of property maxVisibleItems |
getPageSize(): int
Gets current value of property
pageSize
.
The keyboard can be used to navigate through the items of a menu. Beside the arrow keys for single steps and the Home / End keys for jumping to the first / last item, the Page Up / Page Down keys can be used to jump an arbitrary number of items up or down. This number can be defined via the pageSize
property. For values smaller than 1, paging behaves in a similar way to when using the Home / End keys. If the value equals 1, the paging behavior is similar to that of the arrow keys.
Default value is 5
.
- Since:
- 1.25.0
Returns:
{int} | Value of property pageSize |
indexOfItem(oItem): int
Checks for the provided sap.ui.unified.MenuItemBase
in the aggregation items
. and returns its index if found or -1 otherwise.
Parameters:
Returns:
{int} | The index of the provided control in the aggregation if found, or -1 otherwise |
Inserts a item into the aggregation items
.
Parameters:
{sap.ui.unified.MenuItemBase} | 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:
open(bWithKeyboard, oOpenerRef, sMy, sAt, oOf, sOffset?, sCollision?): void
Opens the menu at the specified position.
The position of the menu is defined relative to an element in the visible DOM by specifying the docking location of the menu and of the related element.
See Popup#open for further details about popup positioning.
Parameters:
{boolean} | bWithKeyboard | Indicates whether or not the first item shall be highlighted when the menu is opened (keyboard case) |
{sap.ui.core.Element|DOMRef} | oOpenerRef | The element which will get the focus back again after the menu was closed |
{sap.ui.core.Dock} | sMy | The reference docking location of the menu for positioning the menu on the screen |
{sap.ui.core.Dock} | sAt | The 'of' element's reference docking location for positioning the menu on the screen |
{sap.ui.core.Element|DOMRef} | oOf | The menu is positioned relatively to this element based on the given dock locations |
{string} | sOffset? | The offset relative to the docking point, specified as a string with space-separated pixel values (e.g. "0 10" to move the popup 10 pixels to the right) |
{sap.ui.core.Collision} | sCollision? | The collision defines how the position of the menu should be adjusted in case it overflows the window in some direction |
Removes all the controls in the association named ariaLabelledBy
.
- Since:
- 1.26.3
Returns:
Removes all the controls from the aggregation
items
.
Additionally, it unregisters them from the hosting UIArea.
Returns:
Removes an ariaLabelledBy from the association named ariaLabelledBy
.
Parameters:
{int|string|sap.ui.core.Control} | vAriaLabelledBy | The ariaLabelledByto be removed or its index or ID |
- Since:
- 1.26.3
Returns:
Removes a item from the aggregation items
.
Parameters:
Returns:
Sets a new value for property
enabled
.
When a menu is disabled none of its items can be selected by the user. The enabled property of an item (@link sap.ui.unified.MenuItemBase#getEnabled) has no effect when the menu of the item is disabled.
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:
Sets a new value for property
maxVisibleItems
.
The maximum number of items which are displayed before an overflow mechanism takes effect. A value smaller than 1 means an infinite number of visible items. The overall height of the menu is limited by the height of the screen. If the maximum possible height is reached, an overflow takes effect, even if the maximum number of visible items is not yet reached.
When called with a value of null
or undefined
, the default value of the property will be restored.
Default value is 0
.
Parameters:
{int} | iMaxVisibleItems | New value for property maxVisibleItems |
Returns:
Sets a new value for property
pageSize
.
The keyboard can be used to navigate through the items of a menu. Beside the arrow keys for single steps and the Home / End keys for jumping to the first / last item, the Page Up / Page Down keys can be used to jump an arbitrary number of items up or down. This number can be defined via the pageSize
property. For values smaller than 1, paging behaves in a similar way to when using the Home / End keys. If the value equals 1, the paging behavior is similar to that of the arrow keys.
When called with a value of null
or undefined
, the default value of the property will be restored.
Default value is 5
.
Parameters:
{int} | iPageSize | New value for property pageSize |
- Since:
- 1.25.0
Returns:
getAriaDescription(): string
Gets current value of property
ariaDescription
.
Accessible label / description of the menu for assistive technologies like screenreaders.
- Deprecated:
- Since version 1.27.0 Please use association
ariaLabelledBy
instead.
Returns:
{string} | Value of property ariaDescription |
Sets a new value for property
ariaDescription
.
Accessible label / description of the menu for assistive technologies like screenreaders.
When called with a value of null
or undefined
, the default value of the property will be restored.
Parameters:
{string} | sAriaDescription | New value for property ariaDescription |
- Deprecated:
- Since version 1.27.0 Please use association
ariaLabelledBy
instead.
Returns: