Merge pull request #72099 from bruvzg/ime_commit

[Windows] Fix committing IME text without IME deactivation.
This commit is contained in:
Rémi Verschelde 2023-01-26 09:52:17 +01:00
commit 1cae673b54
No known key found for this signature in database
GPG key ID: C3336907360768E1
3 changed files with 17 additions and 3 deletions

View file

@ -3442,9 +3442,6 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
[[fallthrough]];
}
case WM_CHAR: {
if (windows[window_id].ime_in_progress) {
break;
}
ERR_BREAK(key_event_pos >= KEY_EVENT_BUFFER_SIZE);
// Make sure we don't include modifiers for the modifier key itself.

View file

@ -1724,6 +1724,10 @@ void LineEdit::insert_text_at_caret(String p_text) {
input_direction = (TextDirection)dir;
}
set_caret_column(caret_column + p_text.length());
if (!ime_text.is_empty()) {
_shape();
}
}
void LineEdit::clear_internal() {

View file

@ -3544,6 +3544,19 @@ void TextEdit::insert_text_at_caret(const String &p_text, int p_caret) {
adjust_carets_after_edit(i, new_line, new_column, from_line, from_col);
}
if (!ime_text.is_empty()) {
for (int i = 0; i < carets.size(); i++) {
String t;
if (get_caret_column(i) >= 0) {
t = text[get_caret_line(i)].substr(0, get_caret_column(i)) + ime_text + text[get_caret_line(i)].substr(get_caret_column(i), text[get_caret_line(i)].length());
} else {
t = ime_text;
}
text.invalidate_cache(get_caret_line(i), get_caret_column(i), true, t, structured_text_parser(st_parser, st_args, t));
}
}
end_complex_operation();
queue_redraw();
}