Make dynamic buttons work along with click events
This commit is contained in:
parent
703b5738c8
commit
7857c83ea1
11 changed files with 203 additions and 20 deletions
|
@ -1,6 +1,6 @@
|
|||
'use strict'
|
||||
|
||||
const {ipcMain} = require('electron')
|
||||
const {ipcMain,TouchBar} = require('electron')
|
||||
const {EventEmitter} = require('events')
|
||||
const {BrowserWindow} = process.atomBinding('window')
|
||||
const v8Util = process.atomBinding('v8_util')
|
||||
|
@ -131,6 +131,11 @@ BrowserWindow.prototype._init = function () {
|
|||
return this.webContents.devToolsWebContents
|
||||
}
|
||||
})
|
||||
|
||||
// Proxy TouchBar events
|
||||
this.on('-touch-bar-interaction', (event, item_type, id, ...args) => {
|
||||
TouchBar._event(id, ...args)
|
||||
})
|
||||
}
|
||||
|
||||
BrowserWindow.getFocusedWindow = () => {
|
||||
|
@ -198,4 +203,15 @@ Object.assign(BrowserWindow.prototype, {
|
|||
}
|
||||
})
|
||||
|
||||
// TouchBar API
|
||||
BrowserWindow.prototype.setTouchBar = function (touchBar) {
|
||||
if (touchBar === null || typeof touchBar === 'undefined') {
|
||||
this._destroyTouchBar();
|
||||
} else if (Array.isArray(touchBar)) {
|
||||
this._setTouchBar((new TouchBar(touchBar)).toJSON());
|
||||
} else {
|
||||
this._setTouchBar(touchBar.toJSON())
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = BrowserWindow
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue