Преглед изворни кода

Merge pull request #12268 from AlexHolly/fix-lineedit-selection

Fix LineEdit drag selection to the left
Rémi Verschelde пре 7 година
родитељ
комит
5bbc9a7e66
1 измењених фајлова са 4 додато и 2 уклоњено
  1. 4 2
      scene/gui/line_edit.cpp

+ 4 - 2
scene/gui/line_edit.cpp

@@ -1038,9 +1038,11 @@ void LineEdit::set_cursor_position(int p_pos) {
 	Ref<StyleBox> style = get_stylebox("normal");
 	Ref<StyleBox> style = get_stylebox("normal");
 	Ref<Font> font = get_font("font");
 	Ref<Font> font = get_font("font");
 
 
-	if (cursor_pos < window_pos) {
+	if (cursor_pos <= window_pos) {
 		/* Adjust window if cursor goes too much to the left */
 		/* Adjust window if cursor goes too much to the left */
-		set_window_pos(cursor_pos);
+		if (window_pos > 0)
+			set_window_pos(window_pos - 1);
+
 	} else if (cursor_pos > window_pos) {
 	} else if (cursor_pos > window_pos) {
 		/* Adjust window if cursor goes too much to the right */
 		/* Adjust window if cursor goes too much to the right */
 		int window_width = get_size().width - style->get_minimum_size().width;
 		int window_width = get_size().width - style->get_minimum_size().width;