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.
pull/7132/head
Mitchell Hashimoto 2025-04-18 15:14:14 -07:00
parent 18d6faf597
commit e4a37dd383
No known key found for this signature in database
GPG Key ID: 523D5DC389D273BC
1 changed files with 6 additions and 4 deletions

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