Преглед на файлове

[Windows] Fix committing IME text without IME deactivation.

bruvzg преди 2 години
родител
ревизия
e08a6e692d
променени са 3 файла, в които са добавени 17 реда и са изтрити 3 реда
  1. 0 3
      platform/windows/display_server_windows.cpp
  2. 4 0
      scene/gui/line_edit.cpp
  3. 13 0
      scene/gui/text_edit.cpp

+ 0 - 3
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.

+ 4 - 0
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() {

+ 13 - 0
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();
 }