Reputation: 63
I am writing an OSX App using Electron, and it primarily focuses on the tray. Basically, it only shows when the app is currently being used, how can I set it so that its independant to the window?
Upvotes: 2
Views: 615
Reputation: 5383
You can just create your tray in main process and don't create a window.
const {app, Menu, Tray} = require('electron')
let tray = null
app.on('ready', () => {
tray = new Tray('/path/to/my/icon')
const contextMenu = Menu.buildFromTemplate([
{label: 'Item1', type: 'radio'},
{label: 'Item2', type: 'radio'},
{label: 'Item3', type: 'radio', checked: true},
{label: 'Item4', type: 'radio'}
])
tray.setToolTip('This is my application.')
tray.setContextMenu(contextMenu)
})
Upvotes: 2