Perspective - Toggle Switch
Component Palette Icon:
Description​
The Toggle Switch represents a bit: on (selected) or off (not selected). By default, when the switch is selected the color is blue. It is gray when it is not selected. Logically, this component is very similar to the Checkbox component.
The Toggle Switch component has three pre-configured variants:
- No Text: Default layout with no text.
- Text Right: Layout with text on the right of the Toggle Switch.
- Text Left: Layout with text on the left of the Toggle Switch.
Properties​
Most Properties have binding options. For more information on Bindings, see Types of Bindings in Perspective. This section only documents the Props Category of properties. The other Categories are described on the Perspective Component Properties page.
| Name | Description | Property Type |
|---|---|---|
| selected | The selected state of the Toggle Switch. | value: boolean |
| label | Settings for the label for the Toggle Switch.
| object |
| color | Color settings for the Toggle Switch for each state it is in. Colors can be chosen from a color wheel, color palette, or entered as RGB or HSL values. See the Color Selector page for more information.
| object |
| enabled | Whether the user should be allowed to alter the Toggle Switch's selected state. Default is true.Note: If the component is disabled, scripts can still run on the component. For example, if you add a script action to the onClick event, the script will fire when the user clicks on the Toggle Switch. | value: boolean |
| style | Sets a style for this component. Full menu of style options is available for text, background, margin and padding, border, shape and miscellaneous. You can also specify a style class. | object |
Component Scripts and Events​
Further component interaction and functionality can be configured for all components through scripting and event actions. Right-click on the component or select Components from the Designer menubar to access the configuration popups for both of these options:
- Configure Events: Accesses the Event Configuration popup where you can configure actions to run in response to events to make the component dynamic. The Events Configurations page shows how to configure events and actions on a Perspective component.
- Configure Scripts: Accesses the Script Configuration popup where custom methods and message handlers can be added. The Scripting in Perspective section details scripting fundamentals, creating custom methods, and using message handlers.
Example​
Image above shows both selected and deselected positions for the following properties.
| Property | Value |
|---|---|
| props.label.text | Off / On |
| props.label.position | left |
| props.color.selected | #FF0000 |
| props.color.unselected | #8AFF8A |