Add Slider item type and add options to the button type
This commit is contained in:
parent
18c7c3ece8
commit
c92c4138a8
5 changed files with 191 additions and 53 deletions
|
@ -134,7 +134,7 @@ BrowserWindow.prototype._init = function () {
|
|||
|
||||
// Proxy TouchBar events
|
||||
this.on('-touch-bar-interaction', (event, item_type, id, ...args) => {
|
||||
TouchBar._event(id, ...args)
|
||||
TouchBar._event(item_type, id, ...args)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -23,8 +23,11 @@ class TouchBar {
|
|||
let item_id_incrementor = 1
|
||||
const item_event_handlers = {}
|
||||
|
||||
TouchBar._event = (eventArgs) => {
|
||||
const args = eventArgs.slice(1)
|
||||
TouchBar._event = (itemType, eventArgs) => {
|
||||
let args = eventArgs.slice(1)
|
||||
if (itemType === 'slider') {
|
||||
args = args.map(val => parseInt(val, 10))
|
||||
}
|
||||
const id_parts = eventArgs[0].split('.')
|
||||
const item_id = id_parts[id_parts.length - 1]
|
||||
if (item_event_handlers[item_id]) item_event_handlers[item_id](...args)
|
||||
|
@ -79,11 +82,17 @@ TouchBar.Label = class TouchBarLabel extends TouchBarItem {
|
|||
}
|
||||
}
|
||||
|
||||
TouchBar.List = class TouchBarList extends TouchBarItem {}
|
||||
TouchBar.List = class TouchBarList extends TouchBarItem {
|
||||
constructor (config) {
|
||||
super(config)
|
||||
this.config.type = 'list'
|
||||
}
|
||||
}
|
||||
|
||||
TouchBar.Slider = class TouchBarSlider extends TouchBarItem {
|
||||
constructor (config) {
|
||||
super(config)
|
||||
this.config.type = 'slider';
|
||||
const change = this.config.change
|
||||
if (typeof change === 'function') {
|
||||
item_event_handlers[this.id] = change
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue