From 3c07879504adec0d1b96c10c0f1578c009e070ae Mon Sep 17 00:00:00 2001 From: thedmd Date: Tue, 22 Mar 2022 18:45:27 +0100 Subject: [PATCH] Backends: OSX: Inputs: Monitor NSKeyUp events to catch missing keyUp for key when user press Cmd + key (#5128) --- backends/imgui_impl_osx.mm | 3 ++- docs/CHANGELOG.txt | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/backends/imgui_impl_osx.mm b/backends/imgui_impl_osx.mm index ec0a25b8..3c6635c1 100644 --- a/backends/imgui_impl_osx.mm +++ b/backends/imgui_impl_osx.mm @@ -23,6 +23,7 @@ // CHANGELOG // (minor and older changes stripped away, please see git history for details) +// 2022-03-22: Inputs: Monitor NSKeyUp events to catch missing keyUp for key when user press Cmd + key // 2022-02-07: Inputs: Forward keyDown/keyUp events to OS when unused by dear imgui. // 2022-01-31: Fix building with old Xcode versions that are missing gamepad features. // 2022-01-26: Inputs: replaced short-lived io.AddKeyModsEvent() (added two weeks ago)with io.AddKeyEvent() using ImGuiKey_ModXXX flags. Sorry for the confusion. @@ -429,7 +430,7 @@ bool ImGui_ImplOSX_Init(NSView* view) // Some events do not raise callbacks of AppView in some circumstances (for example when CMD key is held down). // This monitor taps into global event stream and captures these events. - NSEventMask eventMask = NSEventMaskFlagsChanged; + NSEventMask eventMask = NSEventMaskFromType(NSKeyUp) | NSEventMaskFlagsChanged; [NSEvent addLocalMonitorForEventsMatchingMask:eventMask handler:^NSEvent * _Nullable(NSEvent *event) { ImGui_ImplOSX_HandleEvent(event, g_KeyEventResponder); diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 29b6bac7..c6228fbc 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -71,6 +71,7 @@ Other Changes: - ImVector: Fixed erase() with empty range. (#5009) [@thedmd] - Backends: SDL: Fixed dragging out viewport broken on some SDL setups. (#5012) [@rokups] - Backends: SDL: Added support for extra mouse buttons (SDL_BUTTON_X1/SDL_BUTTON_X2). (#5125) [@sgiurgiu] +- Backends: OSX: Monitor NSKeyUp events to catch missing keyUp for key when user press Cmd + key (#5128) [@thedmd] - Examples: Emscripten: Fix building for latest Emscripten specs. (#3632)