类:TouchBarSegmentedControl
类:TouchBarSegmentedControl
¥Class: TouchBarSegmentedControl
创建分段控件(按钮组),其中一个按钮具有选定状态
¥Create a segmented control (a button group) where one button has a selected state
进程:主进程
该类不是从 'electron'
模块导出的。它仅可用作 Electron API 中其他方法的返回值。
¥Process: Main
This class is not exported from the 'electron'
module. It is only available as a return value of other methods in the Electron API.
new TouchBarSegmentedControl(options)
-
options
对象
¥options
Object
-
segmentStyle
字符串(可选) - 片段的样式:
¥segmentStyle
string (optional) - Style of the segments:
-
automatic
- 默认。分段控件的外观是根据显示控件的窗口类型以及窗口内的位置自动确定的。映射到 NSSegmentStyleAutomatic
。
¥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
- 该控件使用圆角样式显示。映射到 NSSegmentStyleRounded
。
¥rounded
- The control is displayed using the rounded style. Maps to NSSegmentStyleRounded
.
-
textured-rounded
- 该控件使用带纹理的圆形样式显示。映射到 NSSegmentStyleTexturedRounded
。
¥textured-rounded
- The control is displayed using the textured rounded
style. Maps to NSSegmentStyleTexturedRounded
.
-
round-rect
- 该控件使用圆角矩形样式显示。映射到 NSSegmentStyleRoundRect
。
¥round-rect
- The control is displayed using the round rect style. Maps to NSSegmentStyleRoundRect
.
-
textured-square
- 该控件使用纹理方形样式显示。映射到 NSSegmentStyleTexturedSquare
。
¥textured-square
- The control is displayed using the textured square
style. Maps to NSSegmentStyleTexturedSquare
.
-
capsule
- 该控件使用胶囊样式显示。映射到 NSSegmentStyleCapsule
。
¥capsule
- The control is displayed using the capsule style. Maps to NSSegmentStyleCapsule
.
-
small-square
- 该控件使用小方块样式显示。映射到 NSSegmentStyleSmallSquare
。
¥small-square
- The control is displayed using the small square style. Maps to NSSegmentStyleSmallSquare
.
-
separated
- 控件中的段显示彼此非常接近,但不接触。映射到 NSSegmentStyleSeparated
。
¥separated
- The segments in the control are displayed very close to each
other but not touching. Maps to NSSegmentStyleSeparated
.
-
mode
字符串(可选) - 控件的选择方式:
¥mode
string (optional) - The selection mode of the control:
-
single
- 默认。一次选择一项,选择一项将取消选择先前选择的项目。映射到 NSSegmentSwitchTrackingSelectOne
。
¥single
- Default. One item selected at a time, selecting one deselects the previously selected item. Maps to NSSegmentSwitchTrackingSelectOne
.
-
multiple
- 一次可以选择多个项目。映射到 NSSegmentSwitchTrackingSelectAny
。
¥multiple
- Multiple items can be selected at a time. Maps to NSSegmentSwitchTrackingSelectAny
.
-
buttons
- 使分段充当按钮,每个分段都可以按下和释放,但永远不会标记为活动状态。映射到 NSSegmentSwitchTrackingMomentary
。
¥buttons
- Make the segments act as buttons, each segment can be pressed and released but never marked as active. Maps to NSSegmentSwitchTrackingMomentary
.
-
segments
SegmentedControlSegment[] - 要放置在此控件中的段数组。
¥segments
SegmentedControlSegment[] - An array of segments to place in this control.
-
selectedIndex
整数(可选) - 当前所选段的索引将随着用户交互自动更新。当模式为 multiple
时,它将是最后选择的项目。
¥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.
-
change
功能(可选) - 当用户选择新段时调用。
¥change
Function (optional) - Called when the user selects a new segment.
-
selectedIndex
整数 - 用户选择的段的索引。
¥selectedIndex
Integer - The index of the segment the user selected.
-
isSelected
布尔值 - 无论作为用户选择的结果,该段是否被选择。
¥isSelected
boolean - Whether as a result of user selection the segment is selected or not.
实例属性
¥Instance Properties
以下属性在 TouchBarSegmentedControl
的实例上可用:
¥The following properties are available on instances of TouchBarSegmentedControl
:
touchBarSegmentedControl.segmentStyle
string
代表控制当前段样式。更新此值会立即更新触摸栏中的控件。
¥A string
representing the controls current segment style. Updating this value immediately updates the control
in the touch bar.
touchBarSegmentedControl.segments
代表此控件中的段的 SegmentedControlSegment[]
数组。更新此值会立即更新触摸栏中的控件。更新此数组内的深层属性不会更新触摸栏。
¥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
Integer
代表当前选定的段。更改此值会立即更新触摸栏中的控件。用户与触摸栏的交互将自动更新该值。
¥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.
touchBarSegmentedControl.mode
string
代表控件的当前选择模式。可以是 single
、multiple
或 buttons
。
¥A string
representing the current selection mode of the control. Can be single
, multiple
or buttons
.