diff --git a/.changes/fix-set-menu.md b/.changes/fix-set-menu.md new file mode 100644 index 000000000..3a4ea7502 --- /dev/null +++ b/.changes/fix-set-menu.md @@ -0,0 +1,5 @@ +--- +"tao": patch +--- + +Fixes `set_menu` SystemTray implementation on macOS. diff --git a/src/platform_impl/macos/system_tray.rs b/src/platform_impl/macos/system_tray.rs index c7e35a8ac..78d741552 100644 --- a/src/platform_impl/macos/system_tray.rs +++ b/src/platform_impl/macos/system_tray.rs @@ -173,12 +173,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) {