Skip to content

Commit

Permalink
fix(macOS): fix SystemTrayEvent not emitted after calling set_menu (
Browse files Browse the repository at this point in the history
  • Loading branch information
pewsheen authored and amrbashir committed Jul 10, 2023
1 parent 710d83b commit 019d9e9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changes/macos-fix-set-tray-menu.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tao": patch
---

On macOS, fix `SystemTrayEvent` not emitted after calling `set_menu`.
6 changes: 5 additions & 1 deletion src/platform_impl/macos/system_tray.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,11 @@ impl SystemTray {

pub fn set_menu(&mut self, tray_menu: &Menu) {
unsafe {
self.ns_status_bar.setMenu_(tray_menu.menu);
self.tray_menu = Some(tray_menu.clone());

let tray_target: id = msg_send![self.ns_status_bar.button(), target];
(*tray_target).set_ivar("menu", tray_menu.menu);
let () = msg_send![tray_menu.menu, setDelegate: tray_target];
}
}

Expand Down

0 comments on commit 019d9e9

Please sign in to comment.