Created
June 9, 2020 17:28
-
-
Save oonqt/b4a468486997bfe3e2c213ca22e8b5cd to your computer and use it in GitHub Desktop.
This file contains 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 { BrowserWindow, Tray, Menu, app } = require('electron'); | |
// possible macOS tray bug identified in the electron core | |
let mainWindow; | |
let tray; | |
const startApp = () => { | |
mainWindow = new BrowserWindow({}); | |
tray = new Tray('./icons/tray.png'); | |
const menu = Menu.buildFromTemplate([ | |
{ | |
label: 'some disabled item', | |
enabled: false | |
}, | |
{ | |
label: 'some template item' | |
}, | |
{ | |
type: 'checkbox', | |
checked: false, | |
label: 'Some check box' | |
}, | |
{ | |
type: 'checkbox', | |
checked: false, | |
label: 'another check box' | |
}, | |
{ | |
type: 'separator' | |
}, | |
{ | |
label: 'Some other menu item', | |
click: () => console.log("i got clicked") | |
} | |
]); | |
tray.setContextMenu(menu); | |
tray.setToolTip('MyAppName') | |
} | |
app.on('ready', () => startApp()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment