From f255ecb2413314583b927bb017ccab90f023bce0 Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Fri, 2 Sep 2022 13:56:27 +0300 Subject: [PATCH] [macOS] Simplify handling of menu accelerators, and send event to the focused window instead of main. --- platform/macos/godot_menu_delegate.mm | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/platform/macos/godot_menu_delegate.mm b/platform/macos/godot_menu_delegate.mm index bd394d8415f..376f28d1d08 100644 --- a/platform/macos/godot_menu_delegate.mm +++ b/platform/macos/godot_menu_delegate.mm @@ -59,18 +59,7 @@ } else { // Otherwise redirect event to the engine. if (DisplayServer::get_singleton()) { - DisplayServerMacOS::KeyEvent ke; - - ke.window_id = DisplayServer::MAIN_WINDOW_ID; - ke.macos_state = [event modifierFlags]; - ke.pressed = true; - ke.echo = [event isARepeat]; - ke.keycode = KeyMappingMacOS::remap_key([event keyCode], [event modifierFlags]); - ke.physical_keycode = KeyMappingMacOS::translate_key([event keyCode]); - ke.raw = false; - ke.unicode = 0; - - reinterpret_cast(DisplayServer::get_singleton())->push_to_key_event_buffer(ke); + [[[NSApplication sharedApplication] keyWindow] sendEvent:event]; } }