macOS: only set unshifted codepoint on keyDown/Up events

Other event types trigger an AppKit assertion that doesn't crash the app
but logs some nasty stuff.
This commit is contained in:
Mitchell Hashimoto
2025-04-18 15:14:14 -07:00
parent 18d6faf597
commit e4a37dd383

View File

@@ -35,10 +35,12 @@ extension NSEvent {
// Our unshifted codepoint is the codepoint with no modifiers. We
// ignore multi-codepoint values.
key_ev.unshifted_codepoint = 0
if let charactersIgnoringModifiers,
let codepoint = charactersIgnoringModifiers.unicodeScalars.first
{
key_ev.unshifted_codepoint = codepoint.value
if type == .keyDown || type == .keyUp {
if let charactersIgnoringModifiers,
let codepoint = charactersIgnoringModifiers.unicodeScalars.first
{
key_ev.unshifted_codepoint = codepoint.value
}
}
return key_ev