From 084fa4c3fac87785dec3142c23f4a171a6bae4a1 Mon Sep 17 00:00:00 2001
From: Guldoman <[EMAIL REDACTED]>
Date: Tue, 1 Nov 2022 10:55:17 +0100
Subject: [PATCH] cocoa: Reset IME when sending composed text
This will send an empty `TEXTEDITING` event that is used to signal the
end of the composition.
---
src/video/cocoa/SDL_cocoakeyboard.m | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/video/cocoa/SDL_cocoakeyboard.m b/src/video/cocoa/SDL_cocoakeyboard.m
index 863e96087731..096b71a4c34b 100644
--- a/src/video/cocoa/SDL_cocoakeyboard.m
+++ b/src/video/cocoa/SDL_cocoakeyboard.m
@@ -66,6 +66,11 @@ - (void)insertText:(id)aString replacementRange:(NSRange)replacementRange
str = [aString UTF8String];
}
+ /* We're likely sending the composed text, so we reset the IME status. */
+ if ([self hasMarkedText]) {
+ [self unmarkText];
+ }
+
SDL_SendKeyboardText(str);
}
@@ -114,7 +119,7 @@ - (void)setMarkedText:(id)aString selectedRange:(NSRange)selectedRange replaceme
(int) selectedRange.location, (int) selectedRange.length);
DEBUG_IME(@"setMarkedText: %@, (%d, %d)", _markedText,
- selRange.location, selRange.length);
+ selectedRange.location, selectedRange.length);
}
- (void)unmarkText