Class “Switch”
Object
> NativeObject
> Widget
> Switch
A switch widget that can be toggled.
Constructor | public |
Singleton | No |
Namespace | tabris |
Direct subclasses | None |
JSX support | Element: <Switch/> Parent element: <Composite/> and any widget extending Composite Child elements: None Text content: Not supported |
Example
import {Switch, contentView} from 'tabris';
new Switch()
.onSelect(() => console.log('Switch toggled'))
.appendTo(contentView);
See also:
Constructor
new Switch(properties?)
Parameter | Type | Optional | Description |
---|---|---|---|
properties | Properties<Switch> |
Yes | Sets all key-value pairs in the properties object as widget properties. |
Properties
checked
The checked state of the switch.
Type | boolean |
Default | false |
Settable | Yes |
Change events | Yes |
thumbOffColor
The color of the movable thumb, when switched off.
Type | ColorValue |
Settable | Yes |
Change events | Yes |
thumbOnColor
The color of the movable thumb, when switched on.
Type | ColorValue |
Settable | Yes |
Change events | Yes |
trackOffColor
The color of the track that holds the thumb, when switched off.
Type | ColorValue |
Settable | Yes |
Change events | Yes |
trackOnColor
The color of the track that holds the thumb, when switched on.
Type | ColorValue |
Settable | Yes |
Change events | Yes |
Events
select
Fired when the switch is toggled by the user.
Parameter | Type | Description |
---|---|---|
checked | boolean |
The current value of checked. |
Change Events
checkedChanged
Fired when the checked property has changed.
Parameter | Type | Description |
---|---|---|
value | boolean |
The new value of checked. |
thumbOnColorChanged
Fired when the thumbOnColor property has changed.
Parameter | Type | Description |
---|---|---|
value | ColorValue |
The new value of thumbOnColor. |
thumbOffColorChanged
Fired when the thumbOffColor property has changed.
Parameter | Type | Description |
---|---|---|
value | ColorValue |
The new value of thumbOffColor. |
trackOnColorChanged
Fired when the trackOnColor property has changed.
Parameter | Type | Description |
---|---|---|
value | ColorValue |
The new value of trackOnColor. |
trackOffColorChanged
Fired when the trackOffColor property has changed.
Parameter | Type | Description |
---|---|---|
value | ColorValue |
The new value of trackOffColor. |