Skip to content

Commit

Permalink
enhance: allow show_menu_on_left_click on Windows (#11729)
Browse files Browse the repository at this point in the history
  • Loading branch information
sandercox authored Nov 18, 2024
1 parent 93a3a04 commit d86aacc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .changes/tray-icon-menu-on-left-click-windows.md
Original file line number Diff line number Diff line change
@@ -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)
6 changes: 3 additions & 3 deletions crates/tauri/src/tray/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ impl<R: Runtime> TrayIconBuilder<R> {
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
Expand Down Expand Up @@ -549,9 +549,9 @@ impl<R: Runtime> TrayIcon<R> {
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))?;
Expand Down
4 changes: 2 additions & 2 deletions packages/api/src/tray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<void> {
return invoke('plugin:tray|set_show_menu_on_left_click', {
rid: this.rid,
Expand Down

0 comments on commit d86aacc

Please sign in to comment.