Initial support for dynamic properties

This commit is contained in:
Kevin Sawicki 2017-02-28 16:08:12 -08:00
parent cbb6f8c33e
commit 98f5858b11
10 changed files with 46 additions and 33 deletions

View file

@ -138,6 +138,8 @@ BrowserWindow.prototype._init = function () {
this._touchBar.emit('interaction', id, details)
}
})
this._touchBarListener = this._refreshTouchBarItem.bind(this)
}
BrowserWindow.getFocusedWindow = () => {
@ -208,8 +210,11 @@ Object.assign(BrowserWindow.prototype, {
// 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()
this._touchBar = null
return
}
@ -218,11 +223,8 @@ BrowserWindow.prototype.setTouchBar = function (touchBar) {
}
this._touchBar = touchBar
this._touchBar.on('change', this._touchBarListener)
this._setTouchBar(touchBar.ordereredItems)
}
BrowserWindow.prototype._updateTouchBarItem = function (itemID) {
this._refreshTouchBarItem(itemID)
}
module.exports = BrowserWindow