Add window helpers to TouchBar class
This commit is contained in:
parent
347d472841
commit
d5dbe3676e
2 changed files with 53 additions and 31 deletions
|
@ -131,15 +131,6 @@ BrowserWindow.prototype._init = function () {
|
|||
return this.webContents.devToolsWebContents
|
||||
}
|
||||
})
|
||||
|
||||
// Proxy TouchBar events
|
||||
this.on('-touch-bar-interaction', (event, id, details) => {
|
||||
if (this._touchBar != null) {
|
||||
this._touchBar.emit('interaction', id, details)
|
||||
}
|
||||
})
|
||||
|
||||
this._touchBarListener = this._refreshTouchBarItem.bind(this)
|
||||
}
|
||||
|
||||
BrowserWindow.getFocusedWindow = () => {
|
||||
|
@ -204,27 +195,25 @@ Object.assign(BrowserWindow.prototype, {
|
|||
},
|
||||
capturePage (...args) {
|
||||
return this.webContents.capturePage(...args)
|
||||
},
|
||||
|
||||
// TouchBar API
|
||||
setTouchBar (touchBar) {
|
||||
if (touchBar == null) {
|
||||
if (this._touchBar != null) {
|
||||
this._touchBar._removeFromWindow(this)
|
||||
}
|
||||
this._destroyTouchBar()
|
||||
return
|
||||
}
|
||||
|
||||
if (Array.isArray(touchBar)) {
|
||||
touchBar = new TouchBar(touchBar)
|
||||
}
|
||||
|
||||
this._touchBar = touchBar
|
||||
this._touchBar._addToWindow(this)
|
||||
}
|
||||
})
|
||||
|
||||
// TouchBar API
|
||||
BrowserWindow.prototype.setTouchBar = function (touchBar) {
|
||||
if (touchBar == null) {
|
||||
if (this._touchBar != null) {
|
||||
this._touchBar.removeListener('change', this._touchBarListener)
|
||||
this._touchBar = null
|
||||
}
|
||||
this._destroyTouchBar()
|
||||
return
|
||||
}
|
||||
|
||||
if (Array.isArray(touchBar)) {
|
||||
touchBar = new TouchBar(touchBar)
|
||||
}
|
||||
|
||||
this._touchBar = touchBar
|
||||
this._touchBar.on('change', this._touchBarListener)
|
||||
this._setTouchBar(touchBar.ordereredItems)
|
||||
}
|
||||
|
||||
module.exports = BrowserWindow
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue