Skip to content

Instantly share code, notes, and snippets.

@wisniewski94
Created March 22, 2020 21:17
Show Gist options
  • Save wisniewski94/5ab8485c5376f02c8b82d7407b35bb33 to your computer and use it in GitHub Desktop.
Save wisniewski94/5ab8485c5376f02c8b82d7407b35bb33 to your computer and use it in GitHub Desktop.
const {
app, BrowserWindow, TouchBar, nativeImage,
} = require('electron');
const { TouchBarPopover, TouchBarButton } = TouchBar;
const image = nativeImage.createFromPath('./m.png').resize({ height: 30 });
app.on('ready', () => {
const win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true,
},
});
const touchBar = new TouchBar({
items: [
new TouchBarPopover({
icon: image,
showCloseButton: true,
items: new TouchBar({
items: [
new TouchBarButton({ label: 'pop' })],
}),
}),
new TouchBarPopover({
label: 'Second popover',
showCloseButton: true,
items: new TouchBar({
items: [
new TouchBarButton({ label: 'pop' })],
}),
}),
],
});
win.loadFile('index.html');
win.webContents.openDevTools();
win.setTouchBar(touchBar);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment