Tray.OnDoubleClick and Tray.OnClick produced at the same time #416

Closed
opened 2026-01-29 16:39:01 +00:00 by claunia · 2 comments
Owner

Originally created by @OmiCron07 on GitHub (Nov 27, 2019).

Originally assigned to: @GregorBiswanger on GitHub.

  • Version: 5.30.1

.Net Core 3.0

  • Target: Windows 10

When subscribed to the tray events OnClick and OnDoubleClick, the two events trigger when double-clicking the tray icon. OnClick event should not trigger when double-clicking the tray icon.

Originally created by @OmiCron07 on GitHub (Nov 27, 2019). Originally assigned to: @GregorBiswanger on GitHub. <!-- Which version of Electron.NET CLI and API are you using? --> * **Version**: 5.30.1 <!-- Which version of .NET Core and Node.js are you using (if applicable)? --> .Net Core 3.0 <!-- What target are you building for? --> * **Target**: Windows 10 <!-- Enter your issue details below this comment. --> When subscribed to the tray events OnClick and OnDoubleClick, the two events trigger when double-clicking the tray icon. OnClick event should not trigger when double-clicking the tray icon.
claunia added the bug label 2026-01-29 16:39:01 +00:00
Author
Owner

@GregorBiswanger commented on GitHub (Nov 30, 2019):

I'm sorry, but that's a standard behavior of the native electron. A double-click on a tray icon should not be used normally either. See the following discussion: https://github.com/electron/electron/issues/8952

You could use at most a separate solution using reactive extensions. I see no reason to use a workaround here.

@GregorBiswanger commented on GitHub (Nov 30, 2019): I'm sorry, but that's a standard behavior of the native electron. A double-click on a tray icon should not be used normally either. See the following discussion: https://github.com/electron/electron/issues/8952 You could use at most a separate solution using reactive extensions. I see no reason to use a workaround here.
Author
Owner

@OmiCron07 commented on GitHub (Dec 2, 2019):

Maybe the double-click should not be used in MacOS, but on Windows, all the applications in the system tray work with double-click. So, in Windows, this is a very strange behaviour because it's normal to react to single-click and double-click separately.

By the way, here my simple workaround if other faces the same problem as me:

Electron.Tray.OnClick += async (args, rectangle) => await SingleClickAsync();
Electron.Tray.OnDoubleClick += async (args, rectangle) => await DoubleClickAsync();

public async Task SingleClickAsync()
{
  await Task.Delay(200);

  if (_isDoubleClickEvent)
  {
    return;
  }

  // Put your code here
}

private async Task DoubleClickAsync()
{
  _isDoubleClickEvent = true;

  await Task.Delay(215);
  _isDoubleClickEvent = false;

  // Put your code here
}

It works by triggering the single-click event, async wait some time while the double-click gets triggered, flag as double-click event and when the single-click event resume from the wait, it detects the double-click and returns.

@OmiCron07 commented on GitHub (Dec 2, 2019): Maybe the double-click should not be used in MacOS, but on Windows, all the applications in the system tray work with double-click. So, in Windows, this is a very strange behaviour because it's normal to react to single-click and double-click separately. By the way, here my simple workaround if other faces the same problem as me: ``` Electron.Tray.OnClick += async (args, rectangle) => await SingleClickAsync(); Electron.Tray.OnDoubleClick += async (args, rectangle) => await DoubleClickAsync(); public async Task SingleClickAsync() { await Task.Delay(200); if (_isDoubleClickEvent) { return; } // Put your code here } private async Task DoubleClickAsync() { _isDoubleClickEvent = true; await Task.Delay(215); _isDoubleClickEvent = false; // Put your code here } ``` It works by triggering the single-click event, async wait some time while the double-click gets triggered, flag as double-click event and when the single-click event resume from the wait, it detects the double-click and returns.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#416