跳转至

Touch Bar 分段控件

类:TouchBarSegmentedControl

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

进程: Main
此类不会从 'electron' 模块中导出。它只能作为 Electron API 中其他方法的返回值使用。

new TouchBarSegmentedControl(options)

  • options Object
  • segmentStyle string (optional) - 分段的样式:
    • automatic - 默认。分段控件的外观根据显示该控件的窗口类型以及控件在窗口中的位置 自动确定。映射到 NSSegmentStyleAutomatic。
    • rounded - 该控件使用圆角样式显示。映射到 NSSegmentStyleRounded。
    • textured-rounded - 该控件使用纹理圆角样式显示。映射到 NSSegmentStyleTexturedRounded。
    • round-rect - 该控件使用圆角矩形样式显示。映射到 NSSegmentStyleRoundRect。
    • textured-square - 该控件使用纹理方形样式显示。映射到 NSSegmentStyleTexturedSquare。
    • capsule - 该控件使用胶囊样式显示。映射到 NSSegmentStyleCapsule。
    • small-square - 该控件使用小方形样式显示。映射到 NSSegmentStyleSmallSquare。
    • separated - 控件中的分段显示得非常接近, 但互不接触。映射到 NSSegmentStyleSeparated。
  • mode string (optional) - 控件的选择模式:
    • single - 默认。一次只能选中一项,选择一项会取消选中之前选中的项。映射到 NSSegmentSwitchTrackingSelectOne。
    • multiple - 一次可以选择多项。映射到 NSSegmentSwitchTrackingSelectAny。
    • buttons - 让分段充当按钮,每个分段可以按下并松开,但永远不会被标记为活动状态。映射到 NSSegmentSwitchTrackingMomentary。
  • segments SegmentedControlSegment[] - 一个要放置在此控件中的分段数组。
  • selectedIndex Integer (optional) - 当前选中分段的索引,会随用户交互自动更新。当模式为 multiple 时,它将是最后选中的项。
  • change Function (optional) - 当用户选择新分段时调用。
    • selectedIndex Integer - 用户选择的分段的索引。
    • isSelected boolean - 该分段是否因用户选择而被选中。

实例属性

以下属性可在 TouchBarSegmentedControl 的实例上使用:

touchBarSegmentedControl.segmentStyle

一个 string,表示控件当前的分段样式。更新此值会立即更新触控栏中的控件。

touchBarSegmentedControl.segments

一个 SegmentedControlSegment[] 数组,表示此控件中的分段。更新此值会立即更新触控栏中的控件。更新此数组内部的深层属性不会更新触控栏。

touchBarSegmentedControl.selectedIndex

一个 Integer,表示当前选中的分段。更改此值会立即更新触控栏中的控件。用户与触控栏的交互将自动更新此值。

touchBarSegmentedControl.mode

一个 string,表示控件当前的选择模式。可以是 single、multiple 或 buttons。

本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 el/electron