Skip to content

Commit

Permalink
fix(macOS): correct tray_target in set_menu (#795)
Browse files Browse the repository at this point in the history
  • Loading branch information
pewsheen authored Sep 30, 2023
1 parent cfbf5ef commit e10d493
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changes/fix-set-menu.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tao": patch
---

Fixes `set_menu` SystemTray implementation on macOS.
9 changes: 4 additions & 5 deletions src/platform_impl/macos/system_tray.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,11 @@ impl SystemTray {

pub fn set_menu(&mut self, tray_menu: &Menu) {
unsafe {
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];
(*self.tray_target).set_ivar(TRAY_MENU, tray_menu.menu);
self.ns_status_bar.setMenu_(tray_menu.menu);
let () = msg_send![tray_menu.menu, setDelegate: self.ns_status_bar];
}
self.tray_menu = Some(tray_menu.clone());
}

pub fn set_tooltip(&self, tooltip: &str) {
Expand Down

0 comments on commit e10d493

Please sign in to comment.