81795744cf
* fix: ensure the typescript definitions only export correct value types In typescript there are two main types of "types" you can export, value types (class, const) and definition types (type, interface). The typescript compiler will let anything declared via const or class be used as a value. Unfortunately we were exporting a bunch of things (see the diff) as class/const when they weren't actually exported values. This lead to typescript being happy but the runtime throwing errors (not something we want). This change passes "exported-in" context through our docs, to the parser and then to the definitions generator to ensure we only mark things as exported in the ts defs that we actually export. Fixes #22167 * chore: update typescript-defs * chore: update typescript-defs * chore: fix bad typescript in IPC test * docs: test rendering of new syntax * chore: update per feedback, use same syntax but with 'this is not exportedd' line
56 lines
3.5 KiB
Markdown
56 lines
3.5 KiB
Markdown
## Class: TouchBarSegmentedControl
|
|
|
|
> Create a segmented control (a button group) where one button has a selected state
|
|
|
|
Process: [Main](../glossary.md#main-process)<br />
|
|
_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` Object
|
|
* `segmentStyle` 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`.
|
|
* `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 (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`.
|
|
* `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[]](structures/segmented-control-segment.md) - 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.
|
|
* `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.segmentStyle`
|
|
|
|
A `String` representing the controls current segment style. Updating this value immediately updates the control
|
|
in the touch bar.
|
|
|
|
#### `touchBarSegmentedControl.segments`
|
|
|
|
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`
|
|
|
|
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`
|
|
|
|
A `String` representing the current selection mode of the control. Can be `single`, `multiple` or `buttons`.
|