Support passing escape item to TouchBar constructor
This commit is contained in:
parent
b24b4212c5
commit
414540bfcb
3 changed files with 28 additions and 9 deletions
|
@ -20,17 +20,29 @@ class TouchBar extends EventEmitter {
|
|||
touchBar._addToWindow(window)
|
||||
}
|
||||
|
||||
constructor (items) {
|
||||
constructor (options) {
|
||||
super()
|
||||
|
||||
if (options == null) {
|
||||
throw new Error('Must specify options object as first argument')
|
||||
}
|
||||
|
||||
let {items, escapeItem} = options
|
||||
|
||||
// FIXME Support array as first argument, remove in 2.0
|
||||
if (Array.isArray(options)) {
|
||||
items = options
|
||||
escapeItem = null
|
||||
}
|
||||
|
||||
if (!Array.isArray(items)) {
|
||||
throw new Error('Must specify items array as first argument')
|
||||
items = []
|
||||
}
|
||||
|
||||
this.windowListeners = {}
|
||||
this.items = {}
|
||||
this.ordereredItems = []
|
||||
this.escapeItem = null
|
||||
this.escapeItem = escapeItem
|
||||
this.changeListener = (item) => {
|
||||
this.emit('change', item.id, item.type)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue