Store event listeners in each TouchBar class

This commit is contained in:
Kevin Sawicki 2017-02-28 15:37:15 -08:00
parent 1972e2eff9
commit cbb6f8c33e
8 changed files with 104 additions and 102 deletions

View file

@ -133,8 +133,10 @@ BrowserWindow.prototype._init = function () {
})
// Proxy TouchBar events
this.on('-touch-bar-interaction', (event, itemType, id, ...args) => {
TouchBar._event(itemType, id, ...args)
this.on('-touch-bar-interaction', (event, id, details) => {
if (this._touchBar != null) {
this._touchBar.emit('interaction', id, details)
}
})
}
@ -207,6 +209,7 @@ Object.assign(BrowserWindow.prototype, {
BrowserWindow.prototype.setTouchBar = function (touchBar) {
if (touchBar == null) {
this._destroyTouchBar()
this._touchBar = null
return
}
@ -214,11 +217,8 @@ BrowserWindow.prototype.setTouchBar = function (touchBar) {
touchBar = new TouchBar(touchBar)
}
this._setTouchBar(touchBar.toJSON())
touchBar._owner = this
touchBar.items.forEach((item) => {
item._owner = this
})
this._touchBar = touchBar
this._setTouchBar(touchBar.ordereredItems)
}
BrowserWindow.prototype._updateTouchBarItem = function (itemID) {