From 2554b512c08b83d88d60137262bada6ad3bc4235 Mon Sep 17 00:00:00 2001 From: ocornut Date: Mon, 7 Feb 2022 11:55:24 +0100 Subject: [PATCH] Backends: OSX: Forward keyDown/keyUp events to OS when unused by Dear ImGui. --- backends/imgui_impl_osx.mm | 7 +++++-- docs/CHANGELOG.txt | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/backends/imgui_impl_osx.mm b/backends/imgui_impl_osx.mm index d061ff6b6..205d2dee8 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-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. // 2021-01-20: Inputs: calling new io.AddKeyAnalogEvent() for gamepad support, instead of writing directly to io.NavInputs[]. @@ -131,7 +132,8 @@ static double GetMachAbsoluteTimeInSeconds() - (void)keyDown:(NSEvent*)event { - ImGui_ImplOSX_HandleEvent(event, self); + if (!ImGui_ImplOSX_HandleEvent(event, self)) + [super keyDown:event]; // Call to the macOS input manager system. [self interpretKeyEvents:@[event]]; @@ -139,7 +141,8 @@ static double GetMachAbsoluteTimeInSeconds() - (void)keyUp:(NSEvent*)event { - ImGui_ImplOSX_HandleEvent(event, self); + if (!ImGui_ImplOSX_HandleEvent(event, self)) + [super keyUp:event]; } - (void)insertText:(id)aString replacementRange:(NSRange)replacementRange diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index edfd4667c..bbc5e85d8 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -153,6 +153,7 @@ Other Changes: - Backends: OSX: Added basic Platform IME support. (#3108, #2598) [@liuliu] - Backends: OSX: Fix Game Controller nav mapping to use shoulder for both focusing and tweak speed. (#4759) - Backends: OSX: Fix building with old Xcode versions that are missing gamepad features. [@rokups] +- Backends: OSX: Forward keyDown/keyUp events to OS when unused by Dear ImGui. - Backends: Android, GLUT: Submit keys using io.AddKeyEvent(). Submit keymods using io.AddKeyModsEvent() at the same time. (#2625) - Backends: Android, GLUT: Submit mouse data using io.AddMousePosEvent(), AddMouseButtonEvent(), AddMouseWheelEvent() functions. (#4858) - Backends: OpenGL3: Fixed a buffer overflow in imgui_impl_opengl3_loader.h init (added in 1.86). (#4468, #4830) [@dymk]