diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index a8aa5e70c0..fc1c705b21 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -1266,6 +1266,12 @@ Controls whether to hide cursor when typing. Adds a vibrancy effect to the browser window. Passing `null` or an empty string will remove the vibrancy effect on the window. +#### `win.setTouchBar(touchBar)` _macOS_ + +* `touchBar` TouchBar + +Sets the touchBar layout for the current window. + [blink-feature-string]: https://cs.chromium.org/chromium/src/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.json5?l=62 [quick-look]: https://en.wikipedia.org/wiki/Quick_Look [vibrancy-docs]: https://developer.apple.com/reference/appkit/nsvisualeffectview?language=objc diff --git a/docs/api/touch-bar.md b/docs/api/touch-bar.md new file mode 100644 index 0000000000..68bdaf88a1 --- /dev/null +++ b/docs/api/touch-bar.md @@ -0,0 +1,44 @@ +## Class: TouchBar + +> Create TouchBar layouts for native macOS applications + +Process: [Main](../tutorial/quick-start.md#main-process) + +### `new TouchBar(items)` + +* `items` (TouchBarButton | TouchBarColorPicker | TouchBarGroup | TouchBarLabel | TouchBarPopOver | TouchBarSlider)[] + +Creates a new touch bar. Note any changes to the TouchBar instance +will not affect the rendered TouchBar. To affect the rendered +TouchBar you **must** use either methods on the TouchBar or methods +on the TouchBar* items + +### Instance Methods + +The `menu` object has the following instance methods: + +#### `touchBar.destroy()` + +Immediately destroys the TouchBar instance and will reset the rendered +touch bar. + +## Examples + +The `TouchBar` class is only available in the main process, it is not currently possible to use in the renderer process **even** through the remote module. + +### Main process + +An example of creating a touch bar in the main process: + +```javascript +const {TouchBar, TouchBarButton} = require('electron') + +const touchBar = new TouchBar([ + new TouchBarButton({ + label: 'Example Button', + click: () => console.log('I was clicked') + }) +]) + +mainWindow.setTouchBar(touchBar) +```