Abstract Class sap.ui.unified.MenuItemBaseModule: sap/ui/unified/MenuItemBase

extends Element
known direct subclasses: MenuItem, MenuItemBase, MenuTextFieldItem

Abstract base class for menu item which provides common properties and events for all concrete item implementations.


Since: 1.21.0.
Constructor Summary
new sap.ui.unified.MenuItemBase(sId?, mSettings?)Abstract base class MenuItemBase for menu item elements.
Event Summary
select(oControlEvent)Fired when the item is selected by the user.
Method Summary
sap.ui.unified.MenuItemBase.extend(sClassName, oClassInfo?, FNMetaImpl?)Creates a new subclass of class sap.ui.unified.MenuItemBase with name sClassName and enriches it with the information contained in oClassInfo.
sap.ui.unified.MenuItemBase.getMetadata()Returns a metadata object for class sap.ui.unified.MenuItemBase.
attachSelect(oData?, fnFunction, oListener?)Attaches event handler fnFunction to the select event of this sap.ui.unified.MenuItemBase.
destroySubmenu()Destroys the submenu in the aggregation submenu.
detachSelect(fnFunction, oListener)Detaches event handler fnFunction from the select event of this sap.ui.unified.MenuItemBase.
fireSelect(mArguments?)Fires event select to attached listeners.
getEnabled()Gets current value of property enabled.
getStartsSection()Gets current value of property startsSection.
getSubmenu()Gets content of aggregation submenu.
getVisible()Gets current value of property visible.
hover(bHovered, oMenu)Changes the visual hover state of the menu item.
onAfterRendering()Informs the item that the item HTML is now applied to the DOM.
onSubmenuToggle(bOpened)Event handler which is called whenever the submenu of the item is opened or closed.
render(oRenderManager, oItem, oMenu)Produces the HTML of an item and writes it to render-output-buffer during the rendering of the corresponding menu.
setEnabled(bEnabled)Sets a new value for property enabled.
setStartsSection(bStartsSection)Sets a new value for property startsSection.
setSubmenu(oSubmenu)Sets the aggregated submenu.
setVisible(bVisible)Sets a new value for property visible.
Constructor Detail
new sap.ui.unified.MenuItemBase(sId?, mSettings?)
Abstract base class MenuItemBase for menu item elements. Please use concrete subclasses.

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

In addition, all settings applicable to the base type sap.ui.core.Element 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
select(oControlEvent)
Fired when the item is selected by the user. Note: The event is also available for items which have a submenu. In general, applications must not handle event in this case because the user selection opens the sub menu.
Parameters:
{sap.ui.base.Event}oControlEvent
{sap.ui.base.EventProvider}oControlEvent.getSource
{object}oControlEvent.getParameters
{sap.ui.unified.MenuItemBase}oControlEvent.getParameters.item The current item
Method Detail
sap.ui.unified.MenuItemBase.extend(sClassName, oClassInfo?, FNMetaImpl?): function
Creates a new subclass of class sap.ui.unified.MenuItemBase 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.Element.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.unified.MenuItemBase.getMetadata(): sap.ui.base.Metadata
Returns a metadata object for class sap.ui.unified.MenuItemBase.
Returns:
{sap.ui.base.Metadata} Metadata object describing this class
attachSelect(oData?, fnFunction, oListener?): sap.ui.unified.MenuItemBase
Attaches event handler fnFunction to the select event of this sap.ui.unified.MenuItemBase.

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.MenuItemBase itself.

Fired when the item is selected by the user. Note: The event is also available for items which have a submenu. In general, applications must not handle event in this case because the user selection opens the sub menu.

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.MenuItemBase itself
Returns:
{sap.ui.unified.MenuItemBase} Reference to this in order to allow method chaining
destroySubmenu(): sap.ui.unified.MenuItemBase
Destroys the submenu in the aggregation submenu.
Returns:
{sap.ui.unified.MenuItemBase} Reference to this in order to allow method chaining
detachSelect(fnFunction, oListener): sap.ui.unified.MenuItemBase
Detaches event handler fnFunction from the select event of this sap.ui.unified.MenuItemBase.

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.unified.MenuItemBase} Reference to this in order to allow method chaining
fireSelect(mArguments?): sap.ui.unified.MenuItemBase
Fires event select to attached listeners.

Expects the following event parameters:

  • item of type sap.ui.unified.MenuItemBaseThe current item
Parameters:
{Map}mArguments? The arguments to pass along with the event
Returns:
{sap.ui.unified.MenuItemBase} Reference to this in order to allow method chaining
getEnabled(): boolean
Gets current value of property enabled.

When an item is disabled the item can not be selected by the user. The enabled property of the item has no effect when the menu of the item is disabled (Menu#getEnabled).

Default value is true.

Returns:
{boolean} Value of property enabled
getStartsSection(): boolean
Gets current value of property startsSection.

Defines whether a visual separator should be rendered before the item. Note: If an item is invisible also the separator of this item is not shown.

Default value is false.

Returns:
{boolean} Value of property startsSection
getSubmenu(): sap.ui.unified.Menu
Gets content of aggregation submenu.

An optional submenu of the item which is opened when the item is selected by the user.

Returns:
{sap.ui.unified.Menu}
getVisible(): boolean
Gets current value of property visible.

Invisible items do not appear in the menu.

Default value is true.

Returns:
{boolean} Value of property visible
hover(bHovered, oMenu)
Changes the visual hover state of the menu item.

Subclasses may override this function.

Parameters:
{boolean}bHovered Specifies whether the item is currently hovered or not.
{sap.ui.unified.Menu}oMenu The menu to which this item belongs
onAfterRendering()
Informs the item that the item HTML is now applied to the DOM.

Subclasses may override this function.

onSubmenuToggle(bOpened)
Event handler which is called whenever the submenu of the item is opened or closed.

Subclasses may override this function.

Parameters:
{boolean}bOpened Specifies whether the submenu of the item is opened or closed
render(oRenderManager, oItem, oMenu)
Produces the HTML of an item and writes it to render-output-buffer during the rendering of the corresponding menu.

Subclasses may override this function.

Parameters:
{sap.ui.core.RenderManager}oRenderManager The RenderManager that can be used for writing to the render-output-buffer
{sap.ui.unified.MenuItemBase}oItem The item which should be rendered
{sap.ui.unified.Menu}oMenu The menu to which this item belongs
setEnabled(bEnabled): sap.ui.unified.MenuItemBase
Sets a new value for property enabled.

When an item is disabled the item can not be selected by the user. The enabled property of the item has no effect when the menu of the item is disabled (Menu#getEnabled).

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.ui.unified.MenuItemBase} Reference to this in order to allow method chaining
setStartsSection(bStartsSection): sap.ui.unified.MenuItemBase
Sets a new value for property startsSection.

Defines whether a visual separator should be rendered before the item. Note: If an item is invisible also the separator of this item is not shown.

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

Default value is false.

Parameters:
{boolean}bStartsSection New value for property startsSection
Returns:
{sap.ui.unified.MenuItemBase} Reference to this in order to allow method chaining
setSubmenu(oSubmenu): sap.ui.unified.MenuItemBase
Sets the aggregated submenu.
Parameters:
{sap.ui.unified.Menu}oSubmenu The submenu to set
Returns:
{sap.ui.unified.MenuItemBase} Reference to this in order to allow method chaining
setVisible(bVisible): sap.ui.unified.MenuItemBase
Sets a new value for property visible.

Invisible items do not appear in the menu.

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

Default value is true.

Parameters:
{boolean}bVisible New value for property visible
Returns:
{sap.ui.unified.MenuItemBase} Reference to this in order to allow method chaining