SL-19881 fix assertion failure in [NSEvent characters]

meow-7.2.2
Brad Linden 2023-06-15 14:39:05 -07:00
parent 6f767db349
commit cb8c91ffc8
1 changed files with 10 additions and 1 deletions

View File

@ -550,7 +550,16 @@ attributedStringInfo getSegments(NSAttributedString *str)
if (mModifiers & mask)
{
eventData.mKeyEvent = NativeKeyEventData::KEYDOWN;
callKeyDown(&eventData, [theEvent keyCode], 0, [[theEvent characters] characterAtIndex:0]);
wchar_t c = 0;
if([theEvent type] == NSEventTypeKeyDown)
{
// characters property is only valid when the event is of type KeyDown or KeyUp
// https://developer.apple.com/documentation/appkit/nsevent/1534183-characters?language=objc
c = [[theEvent characters] characterAtIndex:0];
}
callKeyDown(&eventData, [theEvent keyCode], 0, c);
}
else
{