Add static helper to bind touch bar to window
This commit is contained in:
parent
51f1c5a557
commit
f9dd91d54d
2 changed files with 21 additions and 17 deletions
|
@ -3,6 +3,24 @@ const {EventEmitter} = require('events')
|
|||
let itemIdIncrementor = 1
|
||||
|
||||
class TouchBar extends EventEmitter {
|
||||
|
||||
// Bind a touch bar to a window
|
||||
static _setOnWindow (touchBar, window) {
|
||||
if (window._touchBar != null) {
|
||||
window._touchBar._removeFromWindow(window)
|
||||
}
|
||||
|
||||
if (touchBar == null) {
|
||||
window._setTouchBarItems([])
|
||||
return
|
||||
}
|
||||
|
||||
if (Array.isArray(touchBar)) {
|
||||
touchBar = new TouchBar(touchBar)
|
||||
}
|
||||
touchBar._addToWindow(window)
|
||||
}
|
||||
|
||||
constructor (items) {
|
||||
super()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue