ztk::ios::Switch
Makes an on and off switch (UISwitch).
Synopsis
ztk::ios::Switch new ?OPTION VALUE ...?
$stack add switch ?OPTION VALUE ...?
Arguments
| Name |
Type |
Default |
Meaning |
-on |
boolean |
0 |
The state. cget -on gives the state after the taps of the user. |
-enabled |
boolean |
1 |
0 dims the switch, and it ignores taps. |
-command |
script |
empty |
Runs at the global level after the user changes the state, with the switch appended. |
invoke |
method |
|
Changes the state and runs -command, as a tap does. |
-hidden, -accessibilityLabel, -accessibilityHint |
option |
|
As for each view (ztk::ios). |
configure, cget, destroy |
method |
|
As for each object (ztk::ios). |
Return value
new gives the object. invoke gives an empty string.
Errors
| Error |
When |
expected boolean value but got "X" |
-on or -enabled is no boolean. |
unknown option "-X": must be ... |
Another option. |
| Platform |
Works |
| Windows |
No |
| macOS |
No |
| Linux, Wayland |
No |
| Linux, X11 |
No |
| Web |
No |
| iOS |
Yes |
| Android |
No: ztk::android::Switch |
| Headless |
No: the namespace does not exist. |
Example
set screen [ztk::ios::Screen new -title Settings]
set row [$screen add stack -axis horizontal -spacing 12]
$row add label -text "Wi-Fi"
$row add switch -on 1 -command {apply {{sw} {puts [$sw cget -on]}}}
ztk::ios::app root $screen
See also