Tray click event not fired, BalloonClosed event only called once #674

Closed
opened 2026-01-29 16:45:40 +00:00 by claunia · 5 comments
Owner

Originally created by @nazar322 on GitHub (Jun 25, 2021).

Originally assigned to: @GregorBiswanger on GitHub.

  • 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

Originally created by @nazar322 on GitHub (Jun 25, 2021). Originally assigned to: @GregorBiswanger on GitHub. <!-- Please search existing issues to avoid creating duplicates. --> <!-- Which version of Electron.NET CLI and API are you using? --> <!-- Please always try to use latest version before report. --> * **Version**: 11.5.1 <!-- Which version of .NET Core and Node.js are you using (if applicable)? --> * **Node**: v14.17.1 * **.NET Core**: 5.0 <!-- What target are you building for? --> * **Target**: Windows 10 <!-- Enter your issue details below this comment. --> <!-- If you want, you can donate to increase issue priority (https://donorbox.org/electron-net) --> 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](https://github.com/ElectronNET/Electron.NET/files/6717540/TraySampleElectronNet.zip)
claunia added the bug label 2026-01-29 16:45:40 +00:00
Author
Owner

@towerbit commented on GitHub (Sep 26, 2021):

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 commented on GitHub (Sep 26, 2021): 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);
Author
Owner

@GregorBiswanger commented on GitHub (Mar 28, 2023):

🎉🚀 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 commented on GitHub (Mar 28, 2023): 🎉🚀 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!
Author
Owner

@nazar322 commented on GitHub (May 18, 2023):

@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 commented on GitHub (May 18, 2023): @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?
Author
Owner

@nazar322 commented on GitHub (May 18, 2023):

image

@nazar322 commented on GitHub (May 18, 2023): ![image](https://github.com/ElectronNET/Electron.NET/assets/10635299/22910bd3-413e-444c-9aa3-00a819905885)
Author
Owner

@nazar322 commented on GitHub (Nov 15, 2023):

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 commented on GitHub (Nov 15, 2023): 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](https://github.com/ElectronNET/Electron.NET/assets/10635299/f255095d-cd05-4df0-b2c3-71c5782a1b31) and ![image](https://github.com/ElectronNET/Electron.NET/assets/10635299/461bc64e-e74b-452a-b1b3-5043269e0a92) 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; ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#674