From 5af3da4a2cfa0e648dfa87c067deb6745b73bcc8 Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Mon, 5 Jun 2023 14:29:09 +0300 Subject: [PATCH] fix(macos/menu): set native image height to 18 (#746) * fix(macos/menu): set native image height to 18 closes https://github.com/tauri-apps/tauri/issues/7077 * Update menu.rs --- .changes/macos-native-image-menu.md | 5 +++++ src/platform_impl/macos/menu.rs | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 .changes/macos-native-image-menu.md diff --git a/.changes/macos-native-image-menu.md b/.changes/macos-native-image-menu.md new file mode 100644 index 000000000..366b88357 --- /dev/null +++ b/.changes/macos-native-image-menu.md @@ -0,0 +1,5 @@ +--- +"tao": "patch" +--- + +On macOS, force `NativeImage` height to be `18` to have consistent size for all icons and match custom icons. diff --git a/src/platform_impl/macos/menu.rs b/src/platform_impl/macos/menu.rs index f2ec5678c..2e1949b5b 100644 --- a/src/platform_impl/macos/menu.rs +++ b/src/platform_impl/macos/menu.rs @@ -109,9 +109,11 @@ impl MenuItemAttributes { // Available only with CustomMenuItemExtMacOS pub fn set_native_image(&mut self, icon: NativeImage) { unsafe { - let ns_image: id = icon.get_ns_image(); - let image_ref: id = msg_send![class!(NSImage), imageNamed: ns_image]; - let () = msg_send![self.1, setImage: image_ref]; + let named_img: id = icon.get_ns_image(); + let nsimage: id = msg_send![class!(NSImage), imageNamed: named_img]; + let size = NSSize::new(18.0, 18.0); + let _: () = msg_send![nsimage, setSize: size]; + let _: () = msg_send![self.1, setImage: nsimage]; } } }