pop-os / cosmic-epoch

Next generation Cosmic desktop environment
3.15k stars 84 forks source link

[BUG] Electron app tray icon -> onclick not triggering console.log("something") #1014

Open fablevi opened 1 month ago

fablevi commented 1 month ago

This is the code:

const { app, Tray, nativeImage, BrowserWindow, screen, Menu } = require('electron/main')

let tray
let window

app.whenReady().then(() => {
  const icon = nativeImage.createFromPath('./src/icons/icon.png');
  tray = new Tray(icon);
  tray.on('click', function (event) {
    console.log("Asd")
  })
  tray.setToolTip('This is my application.')
  const contextMenu = Menu.buildFromTemplate([
    { label: 'Item1', type: 'radio' },
    { label: 'Item2', type: 'radio' },
    { label: 'Item3', type: 'radio' },
    { label: 'Item4', type: 'radio' }
  ])
  tray.setContextMenu(contextMenu)
})

The click works, because the contextMenu opens, but the console log and anything on the click wont trigger. This works on Gnome 46