Class sap.m.SegmentedButtonModule: sap/m/SegmentedButton

extends Control

SegmentedButton is a horizontal control made of multiple buttons, which can display a title or an image. It automatically resizes the buttons to fit proportionally within the control. When no width is set, the control uses the available width.

Constructor Summary
new sap.m.SegmentedButton(sId?, mSettings?)Constructor for a new SegmentedButton.
Event Summary
select(oControlEvent)Fires when the user selects a button, which returns the ID and button object.
Events borrowed from class sap.ui.core.Control
Method Summary
sap.m.SegmentedButton.extend(sClassName, oClassInfo?, FNMetaImpl?)Creates a new subclass of class sap.m.SegmentedButton with name sClassName and enriches it with the information contained in oClassInfo.
sap.m.SegmentedButton.getMetadata()Returns a metadata object for class sap.m.SegmentedButton.
addAriaDescribedBy(vAriaDescribedBy)Adds some ariaDescribedBy into the association ariaDescribedBy.
addAriaLabelledBy(vAriaLabelledBy)Adds some ariaLabelledBy into the association ariaLabelledBy.
addItem(oItem)Adds some item to the aggregation items.
attachSelect(oData?, fnFunction, oListener?)Attaches event handler fnFunction to the select event of this sap.m.SegmentedButton.
bindItems(oBindingInfo)Binds aggregation items to model data.
bindSelectedKey(oBindingInfo)Binds property selectedKey to model data.
createButton(sText, sURI, bEnabled, sTextDirection?)Adds a Button with a text as title, an URI for an icon, enabled and textDirection.
destroyItems()Destroys all the items in the aggregation items.
detachSelect(fnFunction, oListener)Detaches event handler fnFunction from the select event of this sap.m.SegmentedButton.
fireSelect(mArguments?)Fires event select to attached listeners.
getAriaDescribedBy()Returns array of IDs of the elements which are the current targets of the association ariaDescribedBy.
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.
getSelectedButton()ID of the element which is the current target of the association selectedButton, or null.
getWidth()Gets current value of property width.
indexOfItem(oItem)Checks for the provided sap.m.SegmentedButtonItem in the aggregation items.
insertItem(oItem, iIndex)Inserts a item into the aggregation items.
removeAllAriaDescribedBy()Removes all the controls in the association named ariaDescribedBy.
removeAllAriaLabelledBy()Removes all the controls in the association named ariaLabelledBy.
removeAllItems()Removes all the controls from the aggregation items.
removeAriaDescribedBy(vAriaDescribedBy)Removes an ariaDescribedBy from the association named ariaDescribedBy.
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.
setSelectedButton(vButton)Setter for association selectedButton.
setWidth(sWidth)Sets a new value for property width.
unbindItems()Unbinds aggregation items from model data.
unbindSelectedKey()Unbinds property selectedKey from model data.
addButton(oButton)Adds some button to the aggregation buttons.
destroyButtons()Destroys all the buttons in the aggregation buttons.
getButtons()Gets content of aggregation buttons.
indexOfButton(oButton)Checks for the provided sap.m.Button in the aggregation buttons.
insertButton(oButton, iIndex)Inserts a button into the aggregation buttons.
removeAllButtons()Removes all the controls from the aggregation buttons.
removeButton(vButton)Removes a button from the aggregation buttons.
Constructor Detail
new sap.m.SegmentedButton(sId?, mSettings?)
Constructor for a new SegmentedButton.

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
    • buttons : sap.m.Button[] (default)
    • items : sap.m.SegmentedButtonItem[]
  • Events
    • select : 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
select(oControlEvent)
Fires when the user selects a button, which returns the ID and button object.
Parameters:
{sap.ui.base.Event}oControlEvent
{sap.ui.base.EventProvider}oControlEvent.getSource
{object}oControlEvent.getParameters
{sap.m.Button}oControlEvent.getParameters.button Reference to the button, that has been selected.
{string}oControlEvent.getParameters.id ID of the button, which has been selected.
{string}oControlEvent.getParameters.key Key of the button, which has been selected. This property is only filled when the control is initiated with the items aggregation.
Method Detail
sap.m.SegmentedButton.extend(sClassName, oClassInfo?, FNMetaImpl?): function
Creates a new subclass of class sap.m.SegmentedButton 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.SegmentedButton.getMetadata(): sap.ui.base.Metadata
Returns a metadata object for class sap.m.SegmentedButton.
Returns:
{sap.ui.base.Metadata} Metadata object describing this class
addAriaDescribedBy(vAriaDescribedBy): sap.m.SegmentedButton
Adds some ariaDescribedBy into the association ariaDescribedBy.
Parameters:
{string|sap.ui.core.Control}vAriaDescribedBy the ariaDescribedBy to add; if empty, nothing is inserted
Returns:
{sap.m.SegmentedButton} Reference to this in order to allow method chaining
addAriaLabelledBy(vAriaLabelledBy): sap.m.SegmentedButton
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.SegmentedButton} Reference to this in order to allow method chaining
addItem(oItem): sap.m.SegmentedButton
Adds some item to the aggregation items.
Parameters:
{sap.m.SegmentedButtonItem}oItem the item to add; if empty, nothing is inserted
Since:
1.28
Returns:
{sap.m.SegmentedButton} Reference to this in order to allow method chaining
attachSelect(oData?, fnFunction, oListener?): sap.m.SegmentedButton
Attaches event handler fnFunction to the select event of this sap.m.SegmentedButton.

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

Fires when the user selects a button, which returns the ID and button object.

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.SegmentedButton itself
Returns:
{sap.m.SegmentedButton} Reference to this in order to allow method chaining
bindItems(oBindingInfo): sap.m.SegmentedButton
Binds aggregation items to model data.

See ManagedObject.bindAggregation for a detailed description of the possible properties of oBindingInfo.

Parameters:
{object}oBindingInfo The binding information
Since:
1.28
Returns:
{sap.m.SegmentedButton} Reference to this in order to allow method chaining
bindSelectedKey(oBindingInfo): sap.m.SegmentedButton
Binds property selectedKey to model data.

See ManagedObject.bindProperty for a detailed description of the possible properties of oBindingInfo

Parameters:
{object}oBindingInfo The binding information
Since:
1.28.0
Returns:
{sap.m.SegmentedButton} Reference to this in order to allow method chaining
createButton(sText, sURI, bEnabled, sTextDirection?): sap.m.Button
Adds a Button with a text as title, an URI for an icon, enabled and textDirection. Only one is allowed.
Parameters:
{string}sText Defines the title text of the newly created Button
{sap.ui.core.URI}sURI Icon to be displayed as graphical element within the Button. Density related image will be loaded if image with density awareness name in format [imageName]@[densityValue].[extension] is provided.
{boolean}bEnabled Enables the control (default is true). Buttons that are disabled have other colors than enabled ones, depending on custom settings.
{sap.ui.core.TextDirection}sTextDirection? Element's text directionality with enumerated options
Since:
1.28.0
Returns:
{sap.m.Button} The created Button
destroyItems(): sap.m.SegmentedButton
Destroys all the items in the aggregation items.
Since:
1.28
Returns:
{sap.m.SegmentedButton} Reference to this in order to allow method chaining
detachSelect(fnFunction, oListener): sap.m.SegmentedButton
Detaches event handler fnFunction from the select event of this sap.m.SegmentedButton.

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

Expects the following event parameters:

  • button of type sap.m.ButtonReference to the button, that has been selected.
  • id of type stringID of the button, which has been selected.
  • key of type stringKey of the button, which has been selected. This property is only filled when the control is initiated with the items aggregation.
Parameters:
{Map}mArguments? The arguments to pass along with the event
Returns:
{sap.m.SegmentedButton} Reference to this in order to allow method chaining
getAriaDescribedBy(): sap.ui.core.Control[]
Returns array of IDs of the elements which are the current targets of the association ariaDescribedBy.
Returns:
{sap.ui.core.Control[]}
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[]}
getEnabled(): boolean
Gets current value of property enabled.

Disables all the buttons in the SegmentedButton control. When disabled all the buttons look grey and you cannot focus or click on them.

Default value is true.

Returns:
{boolean} Value of property enabled
Gets content of aggregation items.

Aggregation of items to be displayed. The items set in this aggregation are used as an interface for the buttons displayed by the control. The "items" and "buttons" aggregations should NOT be used simultaneously as it causes the control to work incorrectly.

Since:
1.28
Returns:
{sap.m.SegmentedButtonItem[]}
getSelectedButton(): sap.m.Button
ID of the element which is the current target of the association selectedButton, or null.
Returns:
{sap.m.Button}
getWidth(): sap.ui.core.CSSSize
Gets current value of property width.

Defines the width of the SegmentedButton control. If not set, it uses the minimum required width to make all buttons inside of the same size (based on the biggest button).

Returns:
{sap.ui.core.CSSSize} Value of property width
indexOfItem(oItem): int
Checks for the provided sap.m.SegmentedButtonItem in the aggregation items. and returns its index if found or -1 otherwise.
Parameters:
{sap.m.SegmentedButtonItem}oItem The item whose index is looked for
Since:
1.28
Returns:
{int} The index of the provided control in the aggregation if found, or -1 otherwise
insertItem(oItem, iIndex): sap.m.SegmentedButton
Inserts a item into the aggregation items.
Parameters:
{sap.m.SegmentedButtonItem}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
Since:
1.28
Returns:
{sap.m.SegmentedButton} Reference to this in order to allow method chaining
removeAllAriaDescribedBy(): sap.ui.core.Control[]
Removes all the controls in the association named ariaDescribedBy.
Returns:
{sap.ui.core.Control[]} An array of the removed elements (might be empty)
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)
removeAllItems(): sap.m.SegmentedButtonItem[]
Removes all the controls from the aggregation items.

Additionally, it unregisters them from the hosting UIArea.

Since:
1.28
Returns:
{sap.m.SegmentedButtonItem[]} An array of the removed elements (might be empty)
removeAriaDescribedBy(vAriaDescribedBy): sap.ui.core.Control
Removes an ariaDescribedBy from the association named ariaDescribedBy.
Parameters:
{int|string|sap.ui.core.Control}vAriaDescribedBy The ariaDescribedByto be removed or its index or ID
Returns:
{sap.ui.core.Control} the removed ariaDescribedBy or null
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
removeItem(vItem): sap.m.SegmentedButtonItem
Removes a item from the aggregation items.
Parameters:
{int|string|sap.m.SegmentedButtonItem}vItem The itemto remove or its index or id
Since:
1.28
Returns:
{sap.m.SegmentedButtonItem} The removed item or null
setEnabled(bEnabled): sap.m.SegmentedButton
Sets a new value for property enabled.

Disables all the buttons in the SegmentedButton control. When disabled all the buttons look grey and you cannot focus or click on them.

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.SegmentedButton} Reference to this in order to allow method chaining
setSelectedButton(vButton): sap.m.SegmentedButton
Setter for association selectedButton.
Parameters:
{string|sap.m.Button|null|undefined}vButton New value for association setSelectedButton A sap.m.Button instance which becomes the new target of this selectedButton association. Alternatively, the ID of a sap.m.Button instance may be given as a string. If the value of null, undefined, or an empty string is provided the first item will be selected.
Returns:
{sap.m.SegmentedButton}this this pointer for chaining
setWidth(sWidth): sap.m.SegmentedButton
Sets a new value for property width.

Defines the width of the SegmentedButton control. If not set, it uses the minimum required width to make all buttons inside of the same size (based on the biggest button).

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.SegmentedButton} Reference to this in order to allow method chaining
unbindItems(): sap.m.SegmentedButton
Unbinds aggregation items from model data.
Since:
1.28
Returns:
{sap.m.SegmentedButton} Reference to this in order to allow method chaining
unbindSelectedKey(): sap.m.SegmentedButton
Unbinds property selectedKey from model data.
Since:
1.28.0
Returns:
{sap.m.SegmentedButton} Reference to this in order to allow method chaining
addButton(oButton): sap.m.SegmentedButton
Adds some button to the aggregation buttons.
Parameters:
{sap.m.Button}oButton the button to add; if empty, nothing is inserted
Deprecated:
Since 1.28.0 Instead use the "items" aggregation.
Returns:
{sap.m.SegmentedButton} Reference to this in order to allow method chaining
destroyButtons(): sap.m.SegmentedButton
Destroys all the buttons in the aggregation buttons.
Deprecated:
Since 1.28.0 Instead use the "items" aggregation.
Returns:
{sap.m.SegmentedButton} Reference to this in order to allow method chaining
getButtons(): sap.m.Button[]
Gets content of aggregation buttons.

The buttons of the SegmentedButton control. The items set in this aggregation are used as an interface for the buttons displayed by the control. Only the properties ID, icon, text, enabled and textDirections of the Button control are evaluated. Setting other properties of the button will have no effect. Alternatively, you can use the createButton method to add buttons.

Deprecated:
Since 1.28.0 Instead use the "items" aggregation.
Returns:
{sap.m.Button[]}
indexOfButton(oButton): int
Checks for the provided sap.m.Button in the aggregation buttons. and returns its index if found or -1 otherwise.
Parameters:
{sap.m.Button}oButton The button whose index is looked for
Deprecated:
Since 1.28.0 Instead use the "items" aggregation.
Returns:
{int} The index of the provided control in the aggregation if found, or -1 otherwise
insertButton(oButton, iIndex): sap.m.SegmentedButton
Inserts a button into the aggregation buttons.
Parameters:
{sap.m.Button}oButton the button to insert; if empty, nothing is inserted
{int}iIndex the 0-based index the button should be inserted at; for a negative value of iIndex, the button is inserted at position 0; for a value greater than the current size of the aggregation, the button is inserted at the last position
Deprecated:
Since 1.28.0 Instead use the "items" aggregation.
Returns:
{sap.m.SegmentedButton} Reference to this in order to allow method chaining
removeAllButtons(): sap.m.Button[]
Removes all the controls from the aggregation buttons.

Additionally, it unregisters them from the hosting UIArea.

Deprecated:
Since 1.28.0 Instead use the "items" aggregation.
Returns:
{sap.m.Button[]} An array of the removed elements (might be empty)
removeButton(vButton): sap.m.Button
Removes a button from the aggregation buttons.
Parameters:
{int|string|sap.m.Button}vButton The buttonto remove or its index or id
Deprecated:
Since 1.28.0 Instead use the "items" aggregation.
Returns:
{sap.m.Button} The removed button or null