22fb4f85e5
* docs: document what experimental means explicitly * Apply suggestions from code review Co-Authored-By: Jeremy Apthorp <jeremya@chromium.org> * Update experimental.md Co-authored-by: Jeremy Apthorp <jeremya@chromium.org>
3.2 KiB
3.2 KiB
Class: TouchBarSegmentedControl
Create a segmented control (a button group) where one button has a selected state
Process: Main
new TouchBarSegmentedControl(options)
options
ObjectsegmentStyle
String (optional) - Style of the segments:automatic
- Default. The appearance of the segmented control is automatically determined based on the type of window in which the control is displayed and the position within the window. Maps toNSSegmentStyleAutomatic
.rounded
- The control is displayed using the rounded style. Maps toNSSegmentStyleRounded
.textured-rounded
- The control is displayed using the textured rounded style. Maps toNSSegmentStyleTexturedRounded
.round-rect
- The control is displayed using the round rect style. Maps toNSSegmentStyleRoundRect
.textured-square
- The control is displayed using the textured square style. Maps toNSSegmentStyleTexturedSquare
.capsule
- The control is displayed using the capsule style. Maps toNSSegmentStyleCapsule
.small-square
- The control is displayed using the small square style. Maps toNSSegmentStyleSmallSquare
.separated
- The segments in the control are displayed very close to each other but not touching. Maps toNSSegmentStyleSeparated
.
mode
String (optional) - The selection mode of the control:single
- Default. One item selected at a time, selecting one deselects the previously selected item. Maps toNSSegmentSwitchTrackingSelectOne
.multiple
- Multiple items can be selected at a time. Maps toNSSegmentSwitchTrackingSelectAny
.buttons
- Make the segments act as buttons, each segment can be pressed and released but never marked as active. Maps toNSSegmentSwitchTrackingMomentary
.
segments
SegmentedControlSegment[] - An array of segments to place in this control.selectedIndex
Integer (optional) - The index of the currently selected segment, will update automatically with user interaction. When the mode ismultiple
it will be the last selected item.change
Function (optional) - Called when the user selects a new segment.selectedIndex
Integer - The index of the segment the user selected.isSelected
Boolean - Whether as a result of user selection the segment is selected or not.
Instance Properties
The following properties are available on instances of TouchBarSegmentedControl
:
touchBarSegmentedControl.segmentStyle
A String
representing the controls current segment style. Updating this value immediately updates the control
in the touch bar.
touchBarSegmentedControl.segments
A SegmentedControlSegment[]
array representing the segments in this control. Updating this value immediately
updates the control in the touch bar. Updating deep properties inside this array does not update the touch bar.
touchBarSegmentedControl.selectedIndex
An Integer
representing the currently selected segment. Changing this value immediately updates the control
in the touch bar. User interaction with the touch bar will update this value automatically.