Browse Source

Some docs for touch bar

Samuel Attard 8 years ago
parent
commit
61949657f0
2 changed files with 50 additions and 0 deletions
  1. 6 0
      docs/api/browser-window.md
  2. 44 0
      docs/api/touch-bar.md

+ 6 - 0
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

+ 44 - 0
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)
+```