Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[macOS] Fix crash when using system default menu shortcuts. #83243

Merged
merged 1 commit into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion platform/macos/display_server_macos.mm
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@
}
}

if (value->callback != Callable()) {
if (value->callback.is_valid()) {
MenuCall mc;
mc.tag = value->meta;
mc.callback = value->callback;
Expand Down
26 changes: 14 additions & 12 deletions platform/macos/godot_menu_delegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ - (void)menuDidClose:(NSMenu *)menu {
- (void)menu:(NSMenu *)menu willHighlightItem:(NSMenuItem *)item {
if (item) {
GodotMenuItem *value = [item representedObject];
if (value && value->hover_callback != Callable()) {
if (value && value->hover_callback.is_valid()) {
// If custom callback is set, use it.
value->hover_callback.call(value->meta);
}
Expand All @@ -73,19 +73,21 @@ - (BOOL)menuHasKeyEquivalent:(NSMenu *)menu forEvent:(NSEvent *)event target:(id

if (ev_modifiers == item_modifiers) {
GodotMenuItem *value = [menu_item representedObject];
if (value->key_callback != Callable()) {
// If custom callback is set, use it.
value->key_callback.call(value->meta);
} else {
// Otherwise redirect event to the engine.
if (DisplayServer::get_singleton()) {
[[[NSApplication sharedApplication] keyWindow] sendEvent:event];
if (value) {
if (value->key_callback.is_valid()) {
// If custom callback is set, use it.
value->key_callback.call(value->meta);
} else {
// Otherwise redirect event to the engine.
if (DisplayServer::get_singleton()) {
[[[NSApplication sharedApplication] keyWindow] sendEvent:event];
}
}
}

// Suppress default menu action.
*target = self;
*action = @selector(doNothing:);
// Suppress default menu action.
*target = self;
*action = @selector(doNothing:);
}
return YES;
}
}
Expand Down
Loading