类: TouchBarSegmentedControl

创建一个分段控件(按钮组),其中一个按钮具有选定状态

Process: Main

new TouchBarSegmentedControl(options) 实验功能

  • 参数 对象
    • segmentStyle String (可选) - 分段的样式:
      • 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 to NSSegmentStyleAutomatic.
      • rounded - The control is displayed using the rounded style. Maps to NSSegmentStyleRounded.
      • textured-rounded - The control is displayed using the textured rounded style. Maps to NSSegmentStyleTexturedRounded.
      • round-rect - The control is displayed using the round rect style. Maps to NSSegmentStyleRoundRect.
      • textured-square - The control is displayed using the textured square style. Maps to NSSegmentStyleTexturedSquare.
      • capsule - The control is displayed using the capsule style. Maps to NSSegmentStyleCapsule.
      • small-square - The control is displayed using the small square style. Maps to NSSegmentStyleSmallSquare.
      • separated - The segments in the control are displayed very close to each other but not touching. Maps to NSSegmentStyleSeparated.
    • mode String (可选) - 控件的选择模式:
      • single - Default. One item selected at a time, selecting one deselects the previously selected item. Maps to NSSegmentSwitchTrackingSelectOne.
      • multiple - Multiple items can be selected at a time. Maps to NSSegmentSwitchTrackingSelectAny.
      • buttons - Make the segments act as buttons, each segment can be pressed and released but never marked as active. Maps to NSSegmentSwitchTrackingMomentary.
    • segments SegmentedControlSegment[] - 被放到控件中的段的集合
    • selectedIndex Integer (optional) - 当前选中的段的下标, 这个值会在用户交互时自动更改 When the mode is multiple it will be the last selected item.
    • change Function (optional) - Called when the user selects a new segment.
      • selectedIndex Integer - 用户选中的段的下标。
      • isSelected Boolean - 当前段的选中状态

实例属性

以下为 TouchBarSegmentedControl 实例的可用属性:

touchBarSegmentedControl.segmentStyle

String类型表示的当前段的样式. 更新这个值会立即触发更新当前段

touchBarSegmentedControl.segments

SegmentedControlSegment[]类型表示的控件中段的集合 改变这个值会立刻刷新touch bar内的控件。 然而改变数组某元素内的嵌套属性不会刷新touch bar

touchBarSegmentedControl.selectedIndex

Integer类型表示的当前选中段 改变这个值会立即触发更新当前段 用户对触摸条的操作会自动更新这个值