Electron.NET icon indicating copy to clipboard operation
Electron.NET copied to clipboard

Tray click event not fired, BalloonClosed event only called once

Open nazar322 opened this issue 4 years ago • 1 comments

  • Version: 11.5.1
  • Node: v14.17.1
  • .NET Core: 5.0
  • Target: Windows 10

Steps to Reproduce:

  1. Download sample project and run it
  2. Attach debugger to TraySampleElectronNet.exe
  3. Navigate to TrayHelper.cs and place breakpoint on lines 45 and 51
  4. In the app click "Hide to tray" then click on the icon in the tray, breakpoint is not hit
  5. Click "Show tray notification", closing the toast notification causes breakpoint to hit, repeat, the breakpoint no longer being hit

Tray context menu items work fine TraySampleElectronNet.zip

nazar322 avatar Jun 25 '21 16:06 nazar322

OnDoubleClick event can not be fired neither.

  • Version: 13.5.1
  • .Net: 5.0
  • Target: Win10
  • Sample code:
    Electron.Tray.OnDoubleClick  += (args, rect) =>
  {
  	Console.WriteLine("Electron.Tray.OnDoubleClick");
  	RestoreFromTray();
  };
    Electron.Tray.Show(iconPath, menuItems);

towerbit avatar Sep 26 '21 02:09 towerbit

🎉🚀 New Electron.NET version 23.6.1 released 🚀🎉

With native Electron 23 and .NET 6 support. Your problem should be fixed here. If you continue to have the problem, please let us know. Please note the correct updating of your API & CLI. Info in the README. Have fun!

GregorBiswanger avatar Mar 28 '23 15:03 GregorBiswanger

@GregorBiswanger still nor Electron.Tray.OnClick or Electron.Tray.OnDoubleClick does fire an event. Electron.CLI 23.6.1. How can I help to reproduce?

nazar322 avatar May 18 '23 16:05 nazar322

image

nazar322 avatar May 18 '23 16:05 nazar322

The interesting part is that you have to first call Show method, ONLY THEN AFTER YOU CAN SUBSCRIBE TO TRAY EVENTS! Thx to this beautiful if statement in the native implementation. image and image

So that is why this fails

Electron.Tray.OnClick += OnTrayIconClick;
Electron.Tray.Show(iconPath, menuItems); 

BUT NOT THIS

Electron.Tray.Show(iconPath, menuItems);
Electron.Tray.OnClick += OnTrayIconClick;

nazar322 avatar Nov 15 '23 11:11 nazar322