Skip to content

Instantly share code, notes, and snippets.

@oonqt
Created June 9, 2020 17:28
Show Gist options
  • Save oonqt/b4a468486997bfe3e2c213ca22e8b5cd to your computer and use it in GitHub Desktop.
Save oonqt/b4a468486997bfe3e2c213ca22e8b5cd to your computer and use it in GitHub Desktop.
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