Skip to content

Commit f9c89b1

Browse files
authored
[Mac] Make sure emulated text input is generated after key down (#14407)
* [Mac] Make sure emulated text input is generated after key down * Don't send AvnKeyEnter as line breaks * Revert some changes
1 parent 8e479e5 commit f9c89b1

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

native/Avalonia.Native/src/OSX/AvnView.mm

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,8 @@ - (void)keyDown:(NSEvent *)event
550550
if(hasInputModifier){
551551
if([self handleKeyDown:timestamp withKey:key withPhysicalKey:physicalKey withModifiers:modifiers withKeySymbol:keySymbol]){
552552
//User code has handled the event
553+
_lastKeyDownEvent = nullptr;
554+
553555
return;
554556
}
555557
}
@@ -567,10 +569,14 @@ - (void)keyDown:(NSEvent *)event
567569
//InputMethod not active
568570
else{
569571
auto keyDownHandled = [self handleKeyDown:timestamp withKey:key withPhysicalKey:physicalKey withModifiers:modifiers withKeySymbol:keySymbol];
570-
571-
//Raise text input event for unhandled key down if there is some key symbol and no input modifier is present
572-
if(!keyDownHandled && modifiers == AvnInputModifiersNone && keySymbol != NULL){
573-
_parent->BaseEvents->RawTextInputEvent(timestamp, [keySymbol UTF8String]);
572+
573+
//Raise text input event for unhandled key down
574+
if(!keyDownHandled){
575+
if(keySymbol != nullptr && key != AvnKeyEnter){
576+
auto timestamp = static_cast<uint64_t>([event timestamp] * 1000);
577+
578+
_parent->BaseEvents->RawTextInputEvent(timestamp, [keySymbol UTF8String]);
579+
}
574580
}
575581
}
576582

0 commit comments

Comments
 (0)