enhance: allow show_menu_on_left_click on Windows (#11729)

This commit is contained in:
Sander Cox 2024-11-18 23:25:20 +01:00 committed by GitHub
parent 93a3a043d3
commit d86aaccb0b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 5 deletions

View File

@ -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)

View File

@ -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
@ -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))?;

View File

@ -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<void> {
return invoke('plugin:tray|set_show_menu_on_left_click', {
rid: this.rid,