Skip to content

Commit 2554b51

Browse files
committed
Backends: OSX: Forward keyDown/keyUp events to OS when unused by Dear ImGui.
1 parent c6cab1f commit 2554b51

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

backends/imgui_impl_osx.mm

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
// CHANGELOG
2525
// (minor and older changes stripped away, please see git history for details)
26+
// 2022-02-07: Inputs: Forward keyDown/keyUp events to OS when unused by dear imgui.
2627
// 2022-01-31: Fix building with old Xcode versions that are missing gamepad features.
2728
// 2022-01-26: Inputs: replaced short-lived io.AddKeyModsEvent() (added two weeks ago)with io.AddKeyEvent() using ImGuiKey_ModXXX flags. Sorry for the confusion.
2829
// 2021-01-20: Inputs: calling new io.AddKeyAnalogEvent() for gamepad support, instead of writing directly to io.NavInputs[].
@@ -131,15 +132,17 @@ - (void)viewDidMoveToWindow
131132

132133
- (void)keyDown:(NSEvent*)event
133134
{
134-
ImGui_ImplOSX_HandleEvent(event, self);
135+
if (!ImGui_ImplOSX_HandleEvent(event, self))
136+
[super keyDown:event];
135137

136138
// Call to the macOS input manager system.
137139
[self interpretKeyEvents:@[event]];
138140
}
139141

140142
- (void)keyUp:(NSEvent*)event
141143
{
142-
ImGui_ImplOSX_HandleEvent(event, self);
144+
if (!ImGui_ImplOSX_HandleEvent(event, self))
145+
[super keyUp:event];
143146
}
144147

145148
- (void)insertText:(id)aString replacementRange:(NSRange)replacementRange

docs/CHANGELOG.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ Other Changes:
153153
- Backends: OSX: Added basic Platform IME support. (#3108, #2598) [@liuliu]
154154
- Backends: OSX: Fix Game Controller nav mapping to use shoulder for both focusing and tweak speed. (#4759)
155155
- Backends: OSX: Fix building with old Xcode versions that are missing gamepad features. [@rokups]
156+
- Backends: OSX: Forward keyDown/keyUp events to OS when unused by Dear ImGui.
156157
- Backends: Android, GLUT: Submit keys using io.AddKeyEvent(). Submit keymods using io.AddKeyModsEvent() at the same time. (#2625)
157158
- Backends: Android, GLUT: Submit mouse data using io.AddMousePosEvent(), AddMouseButtonEvent(), AddMouseWheelEvent() functions. (#4858)
158159
- Backends: OpenGL3: Fixed a buffer overflow in imgui_impl_opengl3_loader.h init (added in 1.86). (#4468, #4830) [@dymk]

0 commit comments

Comments
 (0)