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
This commit is contained in:
Amr Bashir
2023-06-05 14:29:09 +03:00
committed by GitHub
parent 813290130e
commit 5af3da4a2c
2 changed files with 10 additions and 3 deletions

View File

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

View File

@@ -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];
}
}
}