Created
March 22, 2020 18:32
-
-
Save wisniewski94/cf786704a39226c85abfefc2008f2dca to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { app, BrowserWindow, TouchBar } = require('electron'); | |
| const { TouchBarLabel, TouchBarButton, TouchBarSpacer } = TouchBar; | |
| const button = new TouchBarButton({ | |
| label: `Count: ${counter}`, | |
| accessibilityLabel: 'Counter', | |
| backgroundColor: '#6ab04c', | |
| click: () => { | |
| update(); | |
| }, | |
| }); | |
| let counter = 0; | |
| const update = () => { | |
| counter += 1; | |
| button.label = `Count: ${counter}`; | |
| }; | |
| const touchBar = new TouchBar({ | |
| items: [ | |
| button, | |
| ], | |
| }); | |
| function createWindow () { | |
| // Create the browser window. | |
| let win = new BrowserWindow({ | |
| width: 800, | |
| height: 600, | |
| webPreferences: { | |
| nodeIntegration: true | |
| } | |
| }) | |
| // and load the index.html of the app. | |
| win.loadFile('index.html'); | |
| win.setTouchBar(touchBar); | |
| } | |
| app.whenReady().then(createWindow) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment