Hello!
I have a big complex application that struggles from a problem when a user presses Cmd+; shortcut on French AZERTY kb layout (the same physical keys as for Cmd+, on the default ABC layout), AppKit generates the following events:
- FlagsChanged for pressed Cmd modifier
- KeyDown with keycode=43 (comma), chars=";"
- KeyDown with keycode=53 (Esc)
- KeyUp with keycode=43 (comma), chars=";"
- FlagsChanged for released Cmd modifier
I discovered that the Esc event comes from the internal method -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] which has a snippet of logic like the following:
/* ... */
if ([event _matchesKeyEquivalent: [NSKeyboardShortcut localizedKeyEquivalentForInput:@"."] modifierMask:NSCommandKeyMask]) {
/* explicitly send an Esc event instead */
}
/* ... */
That looks unexpected, so my first question is why does such a logic exist there?
Anyway, if there is such a logic in AppKit then I should observe the same behaviour in other AppKit apps, right?
But a very simple application (which is essentially just an NSView which logs all keyboard events) doesn't receive an additional Esc event for the same keystroke on the same layout. The difference is that the internal AppKit call [NSKeyboardShortcut localizedKeyEquivalentForInput:@"."] returns @";" in case of my complex app but @"." in case of the simple one.
And now I'm stuck trying to understand that difference, i.e. what could affect the behaviour of the [NSKeyboardShortcut localizedKeyEquivalentForInput:@"."] call since it's an internal AppKit call and there is no documentation for it and I don't know it's real semantic. Could anybody please advise smth?
Thus, I would like to raise the following questions:
- What is real purpose of the AppKit logic expressed by the code snippet above?
- What can affect the behaviour of the
[NSKeyboardShortcut localizedKeyEquivalentForInput:]call? What is its semantic?
macOS SDK 12.3, if it matters.