Class sap.m.ToolbarModule: sap/m/Toolbar

extends Control
implements IBar, Toolbar
known direct subclasses: AnchorBar

The Toolbar control is a horizontal container that is most commonly used to display buttons, labels, selects and various other input controls.

By default, Toolbar items are shrinkable if they have percent-based width (e.g. Input, Slider) or implement the sap.ui.core.IShrinkable interface (e.g. Text, Label). This behavior can be overridden by providing sap.m.ToolbarLayoutData for the Toolbar items.

Note: It is recommended that you use sap.m.OverflowToolbar over Toolbar, unless you want to avoid overflow in favor of shrinking.


Since: 1.16.
Constructor Summary
new sap.m.Toolbar(sId?, mSettings?)Constructor for a new Toolbar.
Field Summary
applyTagAndContextClassForSets classes and tag according to the context in the page.
getHTMLTagGets the HTML tag of the root domref
isContextSensitiveReturns if the bar is sensitive to the container context.
setHTMLTagSets the HTML tag of the root domref
Event Summary
press(oControlEvent)Fired when the user clicks on the toolbar, if the Active property is set to "true".
Events borrowed from class sap.ui.core.Control
Method Summary
sap.m.Toolbar.extend(sClassName, oClassInfo?, FNMetaImpl?)Creates a new subclass of class sap.m.Toolbar with name sClassName and enriches it with the information contained in oClassInfo.
sap.m.Toolbar.getMetadata()Returns a metadata object for class sap.m.Toolbar.
addAriaLabelledBy(vAriaLabelledBy)Adds some ariaLabelledBy into the association ariaLabelledBy.
addContent(oContent)Adds some content to the aggregation content.
attachPress(oData?, fnFunction, oListener?)Attaches event handler fnFunction to the press event of this sap.m.Toolbar.
destroyContent()Destroys all the content in the aggregation content.
detachPress(fnFunction, oListener)Detaches event handler fnFunction from the press event of this sap.m.Toolbar.
firePress(mArguments?)Fires event press to attached listeners.
getActive()Gets current value of property active.
getActiveDesign()Returns the currently applied design property of the Toolbar.
getAriaLabelledBy()Returns array of IDs of the elements which are the current targets of the association ariaLabelledBy.
getContent()Gets content of aggregation content.
getDesign()Gets current value of property design.
getEnabled()Gets current value of property enabled.
getHeight()Gets current value of property height.
getTitleId()Returns the first sap.m.Title control id inside the toolbar for the accessibility
getWidth()Gets current value of property width.
indexOfContent(oContent)Checks for the provided sap.ui.core.Control in the aggregation content.
insertContent(oContent, iIndex)Inserts a content into the aggregation content.
removeAllAriaLabelledBy()Removes all the controls in the association named ariaLabelledBy.
removeAllContent()Removes all the controls from the aggregation content.
removeAriaLabelledBy(vAriaLabelledBy)Removes an ariaLabelledBy from the association named ariaLabelledBy.
removeContent(vContent)Removes a content from the aggregation content.
setActive(bActive)Sets a new value for property active.
setDesign(sDesign)Sets a new value for property design.
setEnabled(bEnabled)Sets a new value for property enabled.
setHeight(sHeight)Sets a new value for property height.
setWidth(sWidth)Sets a new value for property width.
Constructor Detail
new sap.m.Toolbar(sId?, mSettings?)
Constructor for a new Toolbar.

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
    • width : sap.ui.core.CSSSize
    • active : boolean (default: false)
    • enabled : boolean (default: true)
    • height : sap.ui.core.CSSSize (default: )
    • design : sap.m.ToolbarDesign (default: Auto)
  • Aggregations
    • content : sap.ui.core.Control[] (default)
  • Events
    • press : 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
Field Detail
applyTagAndContextClassFor
Sets classes and tag according to the context in the page. Possible contexts are header, footer, subheader
getHTMLTag
Gets the HTML tag of the root domref
isContextSensitive
Returns if the bar is sensitive to the container context. Implementation of the IBar interface
setHTMLTag
Sets the HTML tag of the root domref
Event Detail
press(oControlEvent)
Fired when the user clicks on the toolbar, if the Active property is set to "true".
Parameters:
{sap.ui.base.Event}oControlEvent
{sap.ui.base.EventProvider}oControlEvent.getSource
{object}oControlEvent.getParameters
{sap.ui.core.Control}oControlEvent.getParameters.srcControl The toolbar item that was pressed
Method Detail
sap.m.Toolbar.extend(sClassName, oClassInfo?, FNMetaImpl?): function
Creates a new subclass of class sap.m.Toolbar 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.Toolbar.getMetadata(): sap.ui.base.Metadata
Returns a metadata object for class sap.m.Toolbar.
Returns:
{sap.ui.base.Metadata} Metadata object describing this class
addAriaLabelledBy(vAriaLabelledBy): sap.m.Toolbar
Adds some ariaLabelledBy into the association ariaLabelledBy.
Parameters:
{string|sap.ui.core.Control}vAriaLabelledBy the ariaLabelledBy to add; if empty, nothing is inserted
Returns:
{sap.m.Toolbar} Reference to this in order to allow method chaining
addContent(oContent): sap.m.Toolbar
Adds some content to the aggregation content.
Parameters:
{sap.ui.core.Control}oContent the content to add; if empty, nothing is inserted
Returns:
{sap.m.Toolbar} Reference to this in order to allow method chaining
attachPress(oData?, fnFunction, oListener?): sap.m.Toolbar
Attaches event handler fnFunction to the press event of this sap.m.Toolbar.

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

Fired when the user clicks on the toolbar, if the Active property is set to "true".

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.Toolbar itself
Returns:
{sap.m.Toolbar} Reference to this in order to allow method chaining
destroyContent(): sap.m.Toolbar
Destroys all the content in the aggregation content.
Returns:
{sap.m.Toolbar} Reference to this in order to allow method chaining
detachPress(fnFunction, oListener): sap.m.Toolbar
Detaches event handler fnFunction from the press event of this sap.m.Toolbar.

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.Toolbar} Reference to this in order to allow method chaining
firePress(mArguments?): sap.m.Toolbar
Fires event press to attached listeners.

Expects the following event parameters:

  • srcControl of type sap.ui.core.ControlThe toolbar item that was pressed
Parameters:
{Map}mArguments? The arguments to pass along with the event
Returns:
{sap.m.Toolbar} Reference to this in order to allow method chaining
getActive(): boolean
Gets current value of property active.

Indicates that the whole toolbar is clickable. The Press event is fired only if Active is set to true. Note: This property should be used when there are no interactive controls inside the toolbar and the toolbar itself is meant to be interactive.

Default value is false.

Returns:
{boolean} Value of property active
getActiveDesign(): sap.m.ToolbarDesign
Returns the currently applied design property of the Toolbar.
Returns:
{sap.m.ToolbarDesign}
getAriaLabelledBy(): sap.ui.core.Control[]
Returns array of IDs of the elements which are the current targets of the association ariaLabelledBy.
Returns:
{sap.ui.core.Control[]}
getContent(): sap.ui.core.Control[]
Gets content of aggregation content.

The content of the toolbar.

Returns:
{sap.ui.core.Control[]}
getDesign(): sap.m.ToolbarDesign
Gets current value of property design.

Defines the toolbar design. Note: Design settings are theme-dependent. They also determine the default height of the toolbar.

Default value is Auto.

Since:
1.16.8
Returns:
{sap.m.ToolbarDesign} Value of property design
getEnabled(): boolean
Gets current value of property enabled.

Sets the enabled property of all controls defined in the content aggregation. Note: This property does not apply to the toolbar itself, but rather to its items.

Default value is true.

Returns:
{boolean} Value of property enabled
getHeight(): sap.ui.core.CSSSize
Gets current value of property height.

Defines the height of the control. Note: By default, the Height property depends on the used theme and the Design property.

Default value is .

Returns:
{sap.ui.core.CSSSize} Value of property height
getTitleId(): String
Returns the first sap.m.Title control id inside the toolbar for the accessibility
Since:
1.28
Returns:
{String}
getWidth(): sap.ui.core.CSSSize
Gets current value of property width.

Defines the width of the control. By default, Toolbar is a block element. If the the width is not explicitly set, the control will assume its natural size.

Returns:
{sap.ui.core.CSSSize} Value of property width
indexOfContent(oContent): int
Checks for the provided sap.ui.core.Control in the aggregation content. and returns its index if found or -1 otherwise.
Parameters:
{sap.ui.core.Control}oContent The content whose index is looked for
Returns:
{int} The index of the provided control in the aggregation if found, or -1 otherwise
insertContent(oContent, iIndex): sap.m.Toolbar
Inserts a content into the aggregation content.
Parameters:
{sap.ui.core.Control}oContent the content to insert; if empty, nothing is inserted
{int}iIndex the 0-based index the content should be inserted at; for a negative value of iIndex, the content is inserted at position 0; for a value greater than the current size of the aggregation, the content is inserted at the last position
Returns:
{sap.m.Toolbar} Reference to this in order to allow method chaining
removeAllAriaLabelledBy(): sap.ui.core.Control[]
Removes all the controls in the association named ariaLabelledBy.
Returns:
{sap.ui.core.Control[]} An array of the removed elements (might be empty)
removeAllContent(): sap.ui.core.Control[]
Removes all the controls from the aggregation content.

Additionally, it unregisters them from the hosting UIArea.

Returns:
{sap.ui.core.Control[]} An array of the removed elements (might be empty)
removeAriaLabelledBy(vAriaLabelledBy): sap.ui.core.Control
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
Returns:
{sap.ui.core.Control} the removed ariaLabelledBy or null
removeContent(vContent): sap.ui.core.Control
Removes a content from the aggregation content.
Parameters:
{int|string|sap.ui.core.Control}vContent The contentto remove or its index or id
Returns:
{sap.ui.core.Control} The removed content or null
setActive(bActive): sap.m.Toolbar
Sets a new value for property active.

Indicates that the whole toolbar is clickable. The Press event is fired only if Active is set to true. Note: This property should be used when there are no interactive controls inside the toolbar and the toolbar itself is meant to be interactive.

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

Default value is false.

Parameters:
{boolean}bActive New value for property active
Returns:
{sap.m.Toolbar} Reference to this in order to allow method chaining
setDesign(sDesign): sap.m.Toolbar
Sets a new value for property design.

Defines the toolbar design. Note: Design settings are theme-dependent. They also determine the default height of the toolbar.

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

Default value is Auto.

Parameters:
{sap.m.ToolbarDesign}sDesign New value for property design
Since:
1.16.8
Returns:
{sap.m.Toolbar} Reference to this in order to allow method chaining
setEnabled(bEnabled): sap.m.Toolbar
Sets a new value for property enabled.

Sets the enabled property of all controls defined in the content aggregation. Note: This property does not apply to the toolbar itself, but rather to its items.

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.Toolbar} Reference to this in order to allow method chaining
setHeight(sHeight): sap.m.Toolbar
Sets a new value for property height.

Defines the height of the control. Note: By default, the Height property depends on the used theme and the Design property.

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

Default value is .

Parameters:
{sap.ui.core.CSSSize}sHeight New value for property height
Returns:
{sap.m.Toolbar} Reference to this in order to allow method chaining
setWidth(sWidth): sap.m.Toolbar
Sets a new value for property width.

Defines the width of the control. By default, Toolbar is a block element. If the the width is not explicitly set, the control will assume its natural size.

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.Toolbar} Reference to this in order to allow method chaining