Store event listeners in each TouchBar class
This commit is contained in:
parent
1972e2eff9
commit
cbb6f8c33e
8 changed files with 104 additions and 102 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue