浏览代码

Merge pull request #26073 from karliss/line-edit-home

Allow moving LineEdit visible window left by more than one symbol.
Rémi Verschelde 6 年之前
父节点
当前提交
f41439c84b
共有 1 个文件被更改,包括 1 次插入3 次删除
  1. 1 3
      scene/gui/line_edit.cpp

+ 1 - 3
scene/gui/line_edit.cpp

@@ -1154,9 +1154,7 @@ void LineEdit::set_cursor_position(int p_pos) {
 
 	if (cursor_pos <= window_pos) {
 		/* Adjust window if cursor goes too much to the left */
-		if (window_pos > 0)
-			set_window_pos(window_pos - 1);
-
+		set_window_pos(MAX(0, cursor_pos - 1));
 	} else if (cursor_pos > window_pos) {
 		/* Adjust window if cursor goes too much to the right */
 		int window_width = get_size().width - style->get_minimum_size().width;