Class sap.m.SwitchModule: sap/m/Switch
A switch is a user interface control on mobile devices that is used for change between binary states. The user can also drag the button handle or tap to change the state.
sClassName
and enriches it with the information contained in oClassInfo
.fnFunction
to the change
event of this sap.m.Switch
.fnFunction
from the change
event of this sap.m.Switch
.ariaLabelledBy
.ariaLabelledBy
. 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
- state : boolean (default: false)
- customTextOn : string (default: )
- customTextOff : string (default: )
- enabled : boolean (default: true)
- name : string (default: )
- type : sap.m.SwitchType (default: Default)
- Events
- change : 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.
{string} | sId? | id for the new control, generated automatically if no id is given |
{object} | mSettings? | initial settings for the new control |
{sap.ui.base.Event} | oControlEvent | |
{sap.ui.base.EventProvider} | oControlEvent.getSource | |
{object} | oControlEvent.getParameters | |
{boolean} | oControlEvent.getParameters.state | The new state of the switch. |
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.
{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 |
{function} | Created class / constructor function |
{sap.ui.base.Metadata} | Metadata object describing this class |
ariaLabelledBy
. {string|sap.ui.core.Control} | vAriaLabelledBy | the ariaLabelledBy to add; if empty, nothing is inserted |
- Since:
- 1.27.0
{sap.m.Switch} | Reference to this in order to allow method chaining |
fnFunction
to the change
event of this sap.m.Switch
. 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.Switch
itself.
Triggered when a switch changes the state.
{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.Switch itself |
{sap.m.Switch} | Reference to this in order to allow method chaining |
fnFunction
from the change
event of this sap.m.Switch
. The passed function and listener object must match the ones used for event registration.
{function} | fnFunction | The function to be called, when the event occurs |
{object} | oListener | Context object on which the given function had to be called |
{sap.m.Switch} | Reference to this in order to allow method chaining |
change
to attached listeners. Expects the following event parameters:
state
of typeboolean
The new state of the switch.
{Map} | mArguments? | The arguments to pass along with the event |
{sap.m.Switch} | Reference to this in order to allow method chaining |
ariaLabelledBy
. - Since:
- 1.27.0
{sap.ui.core.Control[]} |
customTextOff
. Custom text for the "OFF" state.
"OFF" translated to the current language is the default value. Beware that the given text will be cut off if available space is exceeded.
Default value is .
{string} | Value of property customTextOff |
customTextOn
. Custom text for the "ON" state.
"ON" translated to the current language is the default value. Beware that the given text will be cut off if available space is exceeded.
Default value is .
{string} | Value of property customTextOn |
enabled
. Whether the switch is enabled.
Default value is true
.
{boolean} | Value of property enabled |
name
. The name to be used in the HTML code for the switch (e.g. for HTML forms that send data to the server via submit).
Default value is .
{string} | Value of property name |
state
. A boolean value indicating whether the switch is on or off.
Default value is false
.
{boolean} | Value of property state |
type
. Type of a Switch. Possibles values "Default", "AcceptReject".
Default value is Default
.
{sap.m.SwitchType} | Value of property type |
ariaLabelledBy
. - Since:
- 1.27.0
{sap.ui.core.Control[]} | An array of the removed elements (might be empty) |
ariaLabelledBy
. {int|string|sap.ui.core.Control} | vAriaLabelledBy | The ariaLabelledByto be removed or its index or ID |
- Since:
- 1.27.0
{sap.ui.core.Control} | the removed ariaLabelledBy or null |
customTextOff
. Custom text for the "OFF" state.
"OFF" translated to the current language is the default value. Beware that the given text will be cut off if available space is exceeded.
When called with a value of null
or undefined
, the default value of the property will be restored.
Default value is .
{string} | sCustomTextOff | New value for property customTextOff |
{sap.m.Switch} | Reference to this in order to allow method chaining |
customTextOn
. Custom text for the "ON" state.
"ON" translated to the current language is the default value. Beware that the given text will be cut off if available space is exceeded.
When called with a value of null
or undefined
, the default value of the property will be restored.
Default value is .
{string} | sCustomTextOn | New value for property customTextOn |
{sap.m.Switch} | Reference to this in order to allow method chaining |
enabled
. Whether the switch is enabled.
When called with a value of null
or undefined
, the default value of the property will be restored.
Default value is true
.
{boolean} | bEnabled | New value for property enabled |
{sap.m.Switch} | Reference to this in order to allow method chaining |
name
. The name to be used in the HTML code for the switch (e.g. for HTML forms that send data to the server via submit).
When called with a value of null
or undefined
, the default value of the property will be restored.
Default value is .
{string} | sName | New value for property name |
{sap.m.Switch} | Reference to this in order to allow method chaining |
{boolean} | bState |
{sap.m.Switch} | this to allow method chaining. |
type
. Type of a Switch. Possibles values "Default", "AcceptReject".
When called with a value of null
or undefined
, the default value of the property will be restored.
Default value is Default
.
{sap.m.SwitchType} | sType | New value for property type |
{sap.m.Switch} | Reference to this in order to allow method chaining |