ztk::ios::Segmented
Makes a segmented control: UISegmentedControl. A tap on an item selects it.
Synopsis
ztk::ios::Segmented new ?OPTION VALUE ...?
$screen add segmented ?OPTION VALUE ...?
Arguments
| Name |
Type |
Default |
Description |
-items |
list |
empty |
The titles of the items. A new list keeps the selected index when it is still an index of the list, and otherwise selects the first item. new and add set -items before -selected. |
-selected |
integer |
0 |
The index of the selected item, from 0. -1 selects no item. A choice of the user changes it; cget reads it from the view. |
-command |
script |
empty |
Runs with the object appended after a choice of the user. |
-enabled |
boolean |
1 |
0 dims the control, and a tap does nothing. |
invoke INDEX |
method |
|
Selects the item INDEX and runs -command, as a choice of the user does (for tests). |
-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.
Errors
| Error |
When |
bad selected "X": must be -1 or an index from 0 to N |
-selected is no index of the items. |
bad selected "X": the list of items is empty |
-selected is not 0, and there is no item. |
expected boolean value but got "X" |
-enabled is no boolean. |
unknown option "-X": must be ... |
Another option. |
Example
set screen [ztk::ios::Screen new -title Card]
$screen add segmented -items {Raw Graded Sealed} -selected 1 \
-command {apply {{c} {puts [lindex [$c cget -items] [$c cget -selected]]}}}
ztk::ios::app root $screen
See also