Touch Bar Segmented Control
类:TouchBarSegmentedControl¶
创建一个分段控件(按钮组),其中有一个按钮处于选中状态。
进程:主进程
此类不会从 'electron' 模块中导出。它只能作为 Electron API 中其他方法的返回值使用。
new TouchBarSegmentedControl(options)¶
optionsObjectsegmentStylestring (可选) - 分段样式:automatic- 默认。分段控件的外观会根据显示控件的窗口类型以及控件在窗口中的位置自动确定。映射到NSSegmentStyleAutomatic。rounded- 控件以圆角样式显示。映射到NSSegmentStyleRounded。textured-rounded- 控件以纹理圆角样式显示。映射到NSSegmentStyleTexturedRounded。round-rect- 控件以圆角矩形样式显示。映射到NSSegmentStyleRoundRect。textured-square- 控件以纹理方形样式显示。映射到NSSegmentStyleTexturedSquare。capsule- 控件以胶囊样式显示。映射到NSSegmentStyleCapsule。small-square- 控件以小方形样式显示。映射到NSSegmentStyleSmallSquare。separated- 控件中的分段会彼此紧挨着显示,但互不接触。映射到NSSegmentStyleSeparated。
modestring (可选) - 控件的选择模式:single- 默认。一次只选中一个项目,选中一个会取消选择先前选中的项目。映射到NSSegmentSwitchTrackingSelectOne。multiple- 可以同时选中多个项目。映射到NSSegmentSwitchTrackingSelectAny。buttons- 使分段充当按钮,每个分段都可以按下和释放,但永远不会被标记为活动状态。映射到NSSegmentSwitchTrackingMomentary。
segmentsSegmentedControlSegment[] - 要放置在此控件中的分段数组。selectedIndexInteger (可选) - 当前选中分段的索引,会随用户交互自动更新。当模式为multiple时,它将是最后选中的项目。changeFunction (可选) - 当用户选择新分段时调用。selectedIndexInteger - 用户选中的分段的索引。isSelectedboolean - 该分段是否因用户选择而处于选中状态。
实例属性¶
以下属性可用于 TouchBarSegmentedControl 的实例:
touchBarSegmentedControl.segmentStyle¶
一个 string,表示控件当前的分段样式。更新此值会立即更新触控栏中的控件。
touchBarSegmentedControl.segments¶
一个 SegmentedControlSegment[] 数组,表示此控件中的分段。更新此值会立即更新触控栏中的控件。更新此数组中的深层属性 不会更新触控栏。
touchBarSegmentedControl.selectedIndex¶
一个 Integer,表示当前选中的分段。更改此值会立即更新触控栏中的控件。用户与触控栏的交互会自动更新此值。
touchBarSegmentedControl.mode¶
一个 string,表示控件当前的选择模式。可以是 single、multiple 或 buttons。
本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 el/electron