Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions platform/macos/native_menu_macos.mm
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,15 @@
NSImage *image = ds->_convert_to_nsimg(obj->img);
[image setSize:NSMakeSize(16, 16)];
[menu_item setImage:image];
#if (__MAC_OS_X_VERSION_MAX_ALLOWED < 270000)
if ([menu_item respondsToSelector:@selector(preferredImageVisibility)]) {
[menu_item setValue:@(1) forKey:@"preferredImageVisibility"];
}
#else
if (@available(macOS 27.0, *)) {
menu_item.preferredImageVisibility = NSMenuItemImageVisibilityVisible;
}
#endif
}
[menu_item setKeyEquivalentModifierMask:KeyMappingMacOS::keycode_get_native_mask(p_accel)];
[menu_item setRepresentedObject:obj];
Expand Down Expand Up @@ -571,6 +580,15 @@
NSImage *image = ds->_convert_to_nsimg(obj->img);
[image setSize:NSMakeSize(16, 16)];
[menu_item setImage:image];
#if (__MAC_OS_X_VERSION_MAX_ALLOWED < 270000)
if ([menu_item respondsToSelector:@selector(preferredImageVisibility)]) {
[menu_item setValue:@(1) forKey:@"preferredImageVisibility"];
}
#else
if (@available(macOS 27.0, *)) {
menu_item.preferredImageVisibility = NSMenuItemImageVisibilityVisible;
}
Comment on lines +588 to +590

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering what prevents us to use the else to put the menu_item logic. Is there a macOS version that we still support that doesn't accept the @available format?

I'm trying to check the documentation on @available, but I can't find the specifics.

@bruvzg bruvzg Aug 24, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

avaliable(macOS 27) and code inside will only compile when building with Xcode 27, which is in beta. The other branch will compile with any older SDK we support and use for official builds, but still act the same on macOS 27. So we can only keep it, but I would prefer to keep both, so cleaning up ifdefs will be easier once Xcode 27 is min supported version.

#endif
}
[menu_item setKeyEquivalentModifierMask:KeyMappingMacOS::keycode_get_native_mask(p_accel)];
[menu_item setRepresentedObject:obj];
Expand Down Expand Up @@ -622,6 +640,15 @@
NSImage *image = ds->_convert_to_nsimg(obj->img);
[image setSize:NSMakeSize(16, 16)];
[menu_item setImage:image];
#if (__MAC_OS_X_VERSION_MAX_ALLOWED < 270000)
if ([menu_item respondsToSelector:@selector(preferredImageVisibility)]) {
[menu_item setValue:@(1) forKey:@"preferredImageVisibility"];
}
#else
if (@available(macOS 27.0, *)) {
menu_item.preferredImageVisibility = NSMenuItemImageVisibilityVisible;
}
#endif
}
[menu_item setKeyEquivalentModifierMask:KeyMappingMacOS::keycode_get_native_mask(p_accel)];
[menu_item setRepresentedObject:obj];
Expand Down Expand Up @@ -1383,6 +1410,15 @@
NSImage *image = ds->_convert_to_nsimg(obj->img);
[image setSize:NSMakeSize(16, 16)];
[menu_item setImage:image];
#if (__MAC_OS_X_VERSION_MAX_ALLOWED < 270000)
if ([menu_item respondsToSelector:@selector(preferredImageVisibility)]) {
[menu_item setValue:@(1) forKey:@"preferredImageVisibility"];
}
#else
if (@available(macOS 27.0, *)) {
menu_item.preferredImageVisibility = NSMenuItemImageVisibilityVisible;
}
#endif
} else {
obj->img = Ref<Image>();
[menu_item setImage:nil];
Expand Down