Add a method to set the escape identifier on the touch bar
This commit is contained in:
parent
3c1a372157
commit
4d6b0fc01b
10 changed files with 66 additions and 1 deletions
|
@ -28,6 +28,7 @@ class TouchBar extends EventEmitter {
|
|||
}
|
||||
|
||||
this.windowListeners = {}
|
||||
this.windows = {}
|
||||
this.items = {}
|
||||
this.ordereredItems = []
|
||||
|
||||
|
@ -49,6 +50,15 @@ class TouchBar extends EventEmitter {
|
|||
})
|
||||
}
|
||||
|
||||
replaceEscapeItem(item) {
|
||||
if (!item) item = {}
|
||||
Object.keys(this.windows).forEach((windowID) => {
|
||||
const window = this.windows[windowID]
|
||||
window._setEscapeTouchBarItem(item)
|
||||
})
|
||||
this._escape = item;
|
||||
}
|
||||
|
||||
_addToWindow (window) {
|
||||
const {id} = window
|
||||
|
||||
|
@ -76,11 +86,15 @@ class TouchBar extends EventEmitter {
|
|||
window.removeListener('closed', removeListeners)
|
||||
window._touchBar = null
|
||||
delete this.windowListeners[id]
|
||||
delete this.windows[id]
|
||||
}
|
||||
window.once('closed', removeListeners)
|
||||
this.windowListeners[id] = removeListeners
|
||||
this.windows[id] = window;
|
||||
|
||||
window._setTouchBarItems(this.ordereredItems)
|
||||
|
||||
if (this._escape) window._setEscapeTouchBarItem(this._escape)
|
||||
}
|
||||
|
||||
_removeFromWindow (window) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue