瀏覽代碼

TextEdit: Moving between words now works across lines.

Fixes #10403
Andreas Haas 8 年之前
父節點
當前提交
3f2d806b02
共有 1 個文件被更改,包括 14 次插入0 次删除
  1. 14 0
      scene/gui/text_edit.cpp

+ 14 - 0
scene/gui/text_edit.cpp

@@ -2248,6 +2248,13 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
 #endif
 					bool prev_char = false;
 					int cc = cursor.column;
+
+					if (cc == 0 && cursor.line > 0) {
+						cursor_set_line(cursor.line - 1);
+						cursor_set_column(text[cursor.line].length());
+						break;
+					}
+
 					while (cc > 0) {
 
 						bool ischar = _is_text_char(text[cursor.line][cc - 1]);
@@ -2305,6 +2312,13 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
 #endif
 					bool prev_char = false;
 					int cc = cursor.column;
+
+					if (cc == text[cursor.line].length() && cursor.line < text.size() - 1) {
+						cursor_set_line(cursor.line + 1);
+						cursor_set_column(0);
+						break;
+					}
+
 					while (cc < text[cursor.line].length()) {
 
 						bool ischar = _is_text_char(text[cursor.line][cc]);