From d86aaccb0b42760bb59bc04d74a6ea234bb64229 Mon Sep 17 00:00:00 2001 From: Sander Cox Date: Mon, 18 Nov 2024 23:25:20 +0100 Subject: [PATCH] enhance: allow show_menu_on_left_click on Windows (#11729) --- .changes/tray-icon-menu-on-left-click-windows.md | 6 ++++++ crates/tauri/src/tray/mod.rs | 6 +++--- packages/api/src/tray.ts | 4 ++-- 3 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 .changes/tray-icon-menu-on-left-click-windows.md diff --git a/.changes/tray-icon-menu-on-left-click-windows.md b/.changes/tray-icon-menu-on-left-click-windows.md new file mode 100644 index 000000000..4b592dae9 --- /dev/null +++ b/.changes/tray-icon-menu-on-left-click-windows.md @@ -0,0 +1,6 @@ +--- +"tauri": patch:bug +--- + +Support for `set_show_menu_on_left_click` was implemented on Windows too. So it +should not be macOS anymore. [tauri-apps/tray-icon#199](https://github.com/tauri-apps/tray-icon/pull/199) diff --git a/crates/tauri/src/tray/mod.rs b/crates/tauri/src/tray/mod.rs index 5c053f52b..75b552bf1 100644 --- a/crates/tauri/src/tray/mod.rs +++ b/crates/tauri/src/tray/mod.rs @@ -307,7 +307,7 @@ impl TrayIconBuilder { self } - /// Whether to show the tray menu on left click or not, default is `true`. **macOS only**. + /// Whether to show the tray menu on left click or not, default is `true`. **macOS & Windows only**. pub fn menu_on_left_click(mut self, enable: bool) -> Self { self.inner = self.inner.with_menu_on_left_click(enable); self @@ -549,9 +549,9 @@ impl TrayIcon { Ok(()) } - /// Disable or enable showing the tray menu on left click. **macOS only**. + /// Disable or enable showing the tray menu on left click. **macOS & Windows only**. pub fn set_show_menu_on_left_click(&self, #[allow(unused)] enable: bool) -> crate::Result<()> { - #[cfg(target_os = "macos")] + #[cfg(any(target_os = "macos", target_os = "windows"))] run_item_main_thread!(self, |self_: Self| self_ .inner .set_show_menu_on_left_click(enable))?; diff --git a/packages/api/src/tray.ts b/packages/api/src/tray.ts index 91f748bc5..befde4a24 100644 --- a/packages/api/src/tray.ts +++ b/packages/api/src/tray.ts @@ -113,7 +113,7 @@ export interface TrayIconOptions { * Use the icon as a [template](https://developer.apple.com/documentation/appkit/nsimage/1520017-template?language=objc). **macOS only**. */ iconAsTemplate?: boolean - /** Whether to show the tray menu on left click or not, default is `true`. **macOS only**. */ + /** Whether to show the tray menu on left click or not, default is `true`. **macOS & Windows only**. */ menuOnLeftClick?: boolean /** A handler for an event on the tray icon. */ action?: (event: TrayIconEvent) => void @@ -278,7 +278,7 @@ export class TrayIcon extends Resource { }) } - /** Disable or enable showing the tray menu on left click. **macOS only**. */ + /** Disable or enable showing the tray menu on left click. **macOS & Windows only**. */ async setMenuOnLeftClick(onLeft: boolean): Promise { return invoke('plugin:tray|set_show_menu_on_left_click', { rid: this.rid,