Created
March 22, 2020 21:08
-
-
Save wisniewski94/99e712feb3dca834d0aedcfa2453a1e3 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, nativeImage, | |
} = require('electron'); | |
const { TouchBarSegmentedControl } = 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 TouchBarSegmentedControl({ | |
segmentStyle: 'automatic', | |
segments: [ | |
{ icon: image }, | |
{ icon: image, label: 'icon with text' }, | |
{ label: 'baz', enabled: false }, | |
{ label: 'bar' }, | |
], | |
selectedIndex: 3, | |
change: (selectedIndex, isSelected) => { | |
console.log(selectedIndex, isSelected); | |
}, | |
}), | |
new TouchBarSegmentedControl({ | |
segmentStyle: 'rounded', | |
mode: 'multiple', | |
segments: [ | |
{ label: 'multiple' }, | |
{ label: 'choice' }, | |
], | |
selectedIndex: 1, | |
}), | |
new TouchBarSegmentedControl({ | |
segmentStyle: 'automatic', | |
mode: 'buttons', | |
segments: [ | |
{ label: 'can\'t be' }, | |
{ label: 'selected' }, | |
], | |
change: (selectedIndex) => { | |
console.log(selectedIndex); | |
}, | |
}), | |
], | |
}); | |
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