Add a method to set the escape identifier on the touch bar

This commit is contained in:
Samuel Attard 2017-03-27 11:22:52 +11:00 committed by Kevin Sawicki
parent 3c1a372157
commit 4d6b0fc01b
10 changed files with 66 additions and 1 deletions

View file

@ -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) {