diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-01-26 09:52:17 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-01-26 09:52:17 +0100 |
commit | 1cae673b54c62cdf3e7bc988694156a3f7a21455 (patch) | |
tree | a3c453a7e0dfb394e6e7f2e30c539cc084944790 | |
parent | b29cd0699ab0f56b66421ab93ef5647ae17f80e8 (diff) | |
parent | e08a6e692da7eee97945e8079e19acf103a0463e (diff) |
Merge pull request #72099 from bruvzg/ime_commit
[Windows] Fix committing IME text without IME deactivation.
-rw-r--r-- | platform/windows/display_server_windows.cpp | 3 | ||||
-rw-r--r-- | scene/gui/line_edit.cpp | 4 | ||||
-rw-r--r-- | scene/gui/text_edit.cpp | 13 |
3 files changed, 17 insertions, 3 deletions
diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index a7e3451297..89a7114583 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -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. diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index e2a5b0c8a3..5aa777b40c 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -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() { diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 77d5dda4f2..723f3fe7af 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -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(); } |