summaryrefslogtreecommitdiffstats
path: root/scene/gui/spin_box.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui/spin_box.cpp')
-rw-r--r--scene/gui/spin_box.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp
index 26dbe1cb0c..bd549a6e4a 100644
--- a/scene/gui/spin_box.cpp
+++ b/scene/gui/spin_box.cpp
@@ -40,7 +40,7 @@ Size2 SpinBox::get_minimum_size() const {
return ms;
}
-void SpinBox::_update_text() {
+void SpinBox::_update_text(bool p_keep_line_edit) {
String value = String::num(get_value(), Math::range_step_decimals(get_step()));
if (is_localizing_numeral_system()) {
value = TS->format_number(value);
@@ -55,7 +55,12 @@ void SpinBox::_update_text() {
}
}
+ if (p_keep_line_edit && value == last_updated_text && value != line_edit->get_text()) {
+ return;
+ }
+
line_edit->set_text_with_selection(value);
+ last_updated_text = value;
}
void SpinBox::_text_submitted(const String &p_string) {
@@ -245,7 +250,7 @@ inline void SpinBox::_adjust_width_for_icon(const Ref<Texture2D> &icon) {
void SpinBox::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_DRAW: {
- _update_text();
+ _update_text(true);
_adjust_width_for_icon(theme_cache.updown_icon);
RID ci = get_canvas_item();