Dont clear marked text on every keyDown event
Let the input system do it for us. That wy we can hopefully use calls to unmarkText as a signal to commit the pre-edit text. Hopefully not clearing the marked text on key down doesnt break anything else.
This commit is contained in:
parent
228364e317
commit
ca9fdadf3c
@ -871,6 +871,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
||||
_GLFWwindow* window;
|
||||
NSTrackingArea* trackingArea;
|
||||
NSMutableAttributedString* markedText;
|
||||
bool unmark_text_called;
|
||||
NSRect markedRect;
|
||||
NSString *input_source_at_last_key_event;
|
||||
}
|
||||
@ -1215,6 +1216,7 @@ is_ascii_control_char(char x) {
|
||||
_glfwInputKeyboard(window, &dummy); // clear pre-edit text
|
||||
}
|
||||
input_source_at_last_key_event = [inpctx.selectedKeyboardInputSource retain];
|
||||
[self unmarkText];
|
||||
}
|
||||
|
||||
const unsigned int keycode = [event keyCode];
|
||||
@ -1222,7 +1224,6 @@ is_ascii_control_char(char x) {
|
||||
const int mods = translateFlags(flags);
|
||||
const uint32_t key = translateKey(keycode, true);
|
||||
const bool process_text = !window->ns.textInputFilterCallback || window->ns.textInputFilterCallback(key, mods, keycode, flags) != 1;
|
||||
[[markedText mutableString] setString:@""];
|
||||
_glfw.ns.text[0] = 0;
|
||||
GLFWkeyevent glfw_keyevent = {.key = key, .native_key = keycode, .action = GLFW_PRESS, .mods = mods};
|
||||
if (!_glfw.ns.unicodeData) {
|
||||
@ -1256,6 +1257,7 @@ is_ascii_control_char(char x) {
|
||||
}
|
||||
debug_key("\x1b[31mPress:\x1b[m native_key: 0x%x (%s) glfw_key: 0x%x %schar_count: %lu deadKeyState: %u repeat: %d ",
|
||||
keycode, safe_name_for_keycode(keycode), key, format_mods(mods), char_count, window->ns.deadKeyState, event.ARepeat);
|
||||
unmark_text_called = false;
|
||||
if (process_text) {
|
||||
// this will call insertText which will fill up _glfw.ns.text
|
||||
[self interpretKeyEvents:[NSArray arrayWithObject:event]];
|
||||
@ -1278,8 +1280,8 @@ is_ascii_control_char(char x) {
|
||||
}
|
||||
}
|
||||
if (is_ascii_control_char(_glfw.ns.text[0])) _glfw.ns.text[0] = 0; // don't send text for ascii control codes
|
||||
debug_key("text: %s glfw_key: %s marked_text: (%s)\n",
|
||||
format_text(_glfw.ns.text), _glfwGetKeyName(key), [[markedText string] UTF8String]);
|
||||
debug_key("text: %s glfw_key: %s unmark_called: %d marked_text: (%s)\n",
|
||||
format_text(_glfw.ns.text), _glfwGetKeyName(key), unmark_text_called, [[markedText string] UTF8String]);
|
||||
if (!window->ns.deadKeyState) {
|
||||
if ([self hasMarkedText]) {
|
||||
glfw_keyevent.text = [[markedText string] UTF8String];
|
||||
@ -1456,6 +1458,7 @@ is_ascii_control_char(char x) {
|
||||
- (void)unmarkText
|
||||
{
|
||||
[[markedText mutableString] setString:@""];
|
||||
unmark_text_called = true;
|
||||
}
|
||||
|
||||
void _glfwPlatformUpdateIMEState(_GLFWwindow *w, const GLFWIMEUpdateEvent *ev) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user