Skip to content

Instantly share code, notes, and snippets.

@wisniewski94
Created March 22, 2020 18:32
Show Gist options
  • Select an option

  • Save wisniewski94/cf786704a39226c85abfefc2008f2dca to your computer and use it in GitHub Desktop.

Select an option

Save wisniewski94/cf786704a39226c85abfefc2008f2dca to your computer and use it in GitHub Desktop.
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