Skip to content

[Mac] Fixes raw keyDown/textInput handling #12774

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions native/Avalonia.Native/src/OSX/AvnView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -537,11 +537,13 @@ - (void)flagsChanged:(NSEvent *)event
- (void)keyDown:(NSEvent *)event
{
_lastKeyHandled = false;

[self keyboardEvent:event withType:KeyDown];

BOOL isKeyDownConsumed = [[self inputContext] handleEvent:event];

if(!_lastKeyHandled){
[[self inputContext] handleEvent:event];
_lastKeyHandled = isKeyDownConsumed == YES;
}
}

Expand All @@ -552,7 +554,6 @@ - (void)keyUp:(NSEvent *)event
}

- (void) doCommandBySelector:(SEL)selector{

}

- (AvnInputModifiers)getModifiers:(NSEventModifierFlags)mod
Expand Down Expand Up @@ -599,8 +600,6 @@ - (NSRange)selectedRange

- (void)setMarkedText:(id)string selectedRange:(NSRange)selectedRange replacementRange:(NSRange)replacementRange
{
_lastKeyHandled = true;

NSString* markedText;

if([string isKindOfClass:[NSAttributedString class]])
Expand Down Expand Up @@ -669,8 +668,7 @@ - (void)insertText:(id)string replacementRange:(NSRange)replacementRange

uint64_t timestamp = static_cast<uint64_t>([NSDate timeIntervalSinceReferenceDate] * 1000);

_lastKeyHandled = _parent->BaseEvents->RawTextInputEvent(timestamp, [text UTF8String]);

_parent->BaseEvents->RawTextInputEvent(timestamp, [text UTF8String]);
}

- (NSUInteger)characterIndexForPoint:(NSPoint)point
Expand Down