فهرست منبع

Fix removing last digit in spinbox while update_on_text_changed is true

Robert Yevdokimov 9 ماه پیش
والد
کامیت
7375fe2173
1فایلهای تغییر یافته به همراه6 افزوده شده و 2 حذف شده
  1. 6 2
      scene/gui/spin_box.cpp

+ 6 - 2
scene/gui/spin_box.cpp

@@ -68,6 +68,10 @@ void SpinBox::_update_text(bool p_keep_line_edit) {
 }
 }
 
 
 void SpinBox::_text_submitted(const String &p_string) {
 void SpinBox::_text_submitted(const String &p_string) {
+	if (p_string.is_empty()) {
+		return;
+	}
+
 	Ref<Expression> expr;
 	Ref<Expression> expr;
 	expr.instantiate();
 	expr.instantiate();
 
 
@@ -284,8 +288,8 @@ void SpinBox::_line_edit_editing_toggled(bool p_toggled_on) {
 			line_edit->select_all();
 			line_edit->select_all();
 		}
 		}
 	} else {
 	} else {
-		// Discontinue because the focus_exit was caused by canceling.
-		if (Input::get_singleton()->is_action_pressed("ui_cancel")) {
+		// Discontinue because the focus_exit was caused by canceling or the text is empty.
+		if (Input::get_singleton()->is_action_pressed("ui_cancel") || line_edit->get_text().is_empty()) {
 			_update_text();
 			_update_text();
 			return;
 			return;
 		}
 		}