From a5088a48af40845a271209379faeea3ba9e4a3cc Mon Sep 17 00:00:00 2001 From: Jonatan Heyman Date: Fri, 26 Jan 2024 01:42:29 +0100 Subject: [PATCH] Open the Heynote window when menu bar icon is left-clicked on Mac --- electron/main/index.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/electron/main/index.ts b/electron/main/index.ts index 335840c..3cd7dc0 100644 --- a/electron/main/index.ts +++ b/electron/main/index.ts @@ -201,11 +201,18 @@ function createTray() { } tray = new Tray(img); tray.setToolTip("Heynote"); - tray.setContextMenu(getTrayMenu(win)); + const menu = getTrayMenu(win) + if (isMac) { + // using tray.setContextMenu() on macOS will open the menu on left-click, so instead we'll + // manually bind the right-click event to open the menu + tray.addListener("right-click", () => { + tray?.popUpContextMenu(menu) + }) + } else { + tray.setContextMenu(menu); + } tray.addListener("click", () => { - if (!isMac) { - win?.show() - } + win?.show() }) }