Cocoa: Fix some key events not being emitted

The key combinations Cmd+Period, Ctrl+Tab and Ctrl+Esc are not passed to
the first responder as key events.

This commit catches and claims these specific key events via the key
equivalents mechanism and emits them from there instead.

Closes #1362
Fixes #2278
This commit is contained in:
Camilla Löwy
2026-06-09 21:20:23 +02:00
parent 0136febb1e
commit 567b1ec244
3 changed files with 32 additions and 0 deletions

View File

@@ -599,6 +599,34 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
_glfwInputKey(window, key, [event keyCode], GLFW_RELEASE, mods);
}
- (BOOL)performKeyEquivalent:(NSEvent *)event
{
// HACK: Some key combinations are consumed before reaching keyDown:
// so we claim those events and emit them here
const int key = translateKey([event keyCode]);
const int mods = translateFlags([event modifierFlags]);
if (mods & GLFW_MOD_CONTROL)
{
if (key == GLFW_KEY_TAB || key == GLFW_KEY_ESCAPE)
{
_glfwInputKey(window, key, [event keyCode], GLFW_PRESS, mods);
return YES;
}
}
if (mods & GLFW_MOD_SUPER)
{
if (key == GLFW_KEY_PERIOD)
{
_glfwInputKey(window, key, [event keyCode], GLFW_PRESS, mods);
return YES;
}
}
return [super performKeyEquivalent:event];
}
- (void)scrollWheel:(NSEvent *)event
{
double deltaX = [event scrollingDeltaX];