Merge pull request #83243 from bruvzg/macos_sys_def_menu_items
[macOS] Fix crash when using system default menu shortcuts.
This commit is contained in:
commit
577fbd8841
|
@ -649,7 +649,7 @@ void DisplayServerMacOS::menu_callback(id p_sender) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value->callback != Callable()) {
|
if (value->callback.is_valid()) {
|
||||||
MenuCall mc;
|
MenuCall mc;
|
||||||
mc.tag = value->meta;
|
mc.tag = value->meta;
|
||||||
mc.callback = value->callback;
|
mc.callback = value->callback;
|
||||||
|
|
|
@ -56,7 +56,7 @@
|
||||||
- (void)menu:(NSMenu *)menu willHighlightItem:(NSMenuItem *)item {
|
- (void)menu:(NSMenu *)menu willHighlightItem:(NSMenuItem *)item {
|
||||||
if (item) {
|
if (item) {
|
||||||
GodotMenuItem *value = [item representedObject];
|
GodotMenuItem *value = [item representedObject];
|
||||||
if (value && value->hover_callback != Callable()) {
|
if (value && value->hover_callback.is_valid()) {
|
||||||
// If custom callback is set, use it.
|
// If custom callback is set, use it.
|
||||||
value->hover_callback.call(value->meta);
|
value->hover_callback.call(value->meta);
|
||||||
}
|
}
|
||||||
|
@ -73,19 +73,21 @@
|
||||||
|
|
||||||
if (ev_modifiers == item_modifiers) {
|
if (ev_modifiers == item_modifiers) {
|
||||||
GodotMenuItem *value = [menu_item representedObject];
|
GodotMenuItem *value = [menu_item representedObject];
|
||||||
if (value->key_callback != Callable()) {
|
if (value) {
|
||||||
// If custom callback is set, use it.
|
if (value->key_callback.is_valid()) {
|
||||||
value->key_callback.call(value->meta);
|
// If custom callback is set, use it.
|
||||||
} else {
|
value->key_callback.call(value->meta);
|
||||||
// Otherwise redirect event to the engine.
|
} else {
|
||||||
if (DisplayServer::get_singleton()) {
|
// Otherwise redirect event to the engine.
|
||||||
[[[NSApplication sharedApplication] keyWindow] sendEvent:event];
|
if (DisplayServer::get_singleton()) {
|
||||||
|
[[[NSApplication sharedApplication] keyWindow] sendEvent:event];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Suppress default menu action.
|
// Suppress default menu action.
|
||||||
*target = self;
|
*target = self;
|
||||||
*action = @selector(doNothing:);
|
*action = @selector(doNothing:);
|
||||||
|
}
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue