Class: TouchBarSegmentedControl
Class: TouchBarSegmentedControl
Create a segmented control (a button group) where one button has a selected state创建一个分段控件(按钮组),其中一个按钮具有选定状态
Process:进程:Main
This class is not exported from the 'electron'
module. 此类不是从'electron'
模块导出的。It is only available as a return value of other methods in the Electron API.它只能作为Electron API中其他方法的返回值使用。
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 to NSSegmentStyleAutomatic
.映射到NSSegmentStyleAutomatic
。
rounded
- The control is displayed using the rounded style. 控件使用圆角样式显示。Maps to NSSegmentStyleRounded
.映射到NSSegmentStyleRounded
。
textured-rounded
- The control is displayed using the textured rounded style. 控件使用带纹理的圆形样式显示。Maps to NSSegmentStyleTexturedRounded
.映射到NSSegmentStyleTexturedRounded
。
round-rect
- The control is displayed using the round rect style. 控件使用圆形矩形样式显示。Maps to NSSegmentStyleRoundRect
.映射到NSSegmentStyleRoundRect
。
textured-square
- The control is displayed using the textured square style. 控件使用带纹理的正方形样式显示。Maps to NSSegmentStyleTexturedSquare
.映射到NSSegmentStyleTexturedSquare
。
capsule
- The control is displayed using the capsule style. 控件使用胶囊样式显示。Maps to NSSegmentStyleCapsule
.映射到NSSegmentStyleCapsule
。
small-square
- The control is displayed using the small square style. 控件使用小方块样式显示。Maps to NSSegmentStyleSmallSquare
.映射到NSSegmentStyleSmallSquare
。
separated
- The segments in the control are displayed very close to each other but not touching. 控件中的分段显示得非常接近,但不接触。Maps to NSSegmentStyleSeparated
.映射到NSSegmentStyleSeparated
。
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 to NSSegmentSwitchTrackingSelectOne
.映射到NSSegmentSwitchTrackingSelectOne
。
multiple
- Multiple items can be selected at a time. 一次可以选择多个项目。Maps to NSSegmentSwitchTrackingSelectAny
.映射到NSSegmentSwitchTrackingSelectAny
。
buttons
- Make the segments act as buttons, each segment can be pressed and released but never marked as active. 使分段充当按钮,每个分段都可以被按下和释放,但永远不会被标记为活动。Maps to NSSegmentSwitchTrackingMomentary
.映射到NSSegmentSwitchTrackingMomentary
。
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 is multiple
it will be the last selected item.当模式为multiple
时,它将是最后一个选择的项目。
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
实例上提供了以下属性:
touchBarSegmentedControl.segmentStyle
A string
representing the controls current segment style. 表示控件当前分段样式的string
。Updating this value immediately updates the control in the touch bar.更新此值会立即更新触摸条中的控件。
touchBarSegmentedControl.segments
A SegmentedControlSegment[]
array representing the segments in this control. SegmentedControlSegment[]
数组,表示此控件中的段。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. 表示当前选定线段的Integer
。Changing this value immediately updates the control in the touch bar. 更改此值会立即更新触摸条中的控件。User interaction with the touch bar will update this value automatically.用户与触摸条的交互将自动更新此值。
touchBarSegmentedControl.mode
A string
representing the current selection mode of the control. 表示控件的当前选择模式的string
。Can be single
, multiple
or buttons
.可以是single
、multiple
或buttons
。