summaryrefslogtreecommitdiff
path: root/scene/gui/range.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui/range.cpp')
-rw-r--r--scene/gui/range.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/scene/gui/range.cpp b/scene/gui/range.cpp
index 2d2b3e413d..27002fad38 100644
--- a/scene/gui/range.cpp
+++ b/scene/gui/range.cpp
@@ -80,6 +80,15 @@ void Range::Shared::emit_changed(const char *p_what) {
}
void Range::set_value(double p_val) {
+ double prev_val = shared->val;
+ set_value_no_signal(p_val);
+
+ if (shared->val != prev_val) {
+ shared->emit_value_changed();
+ }
+}
+
+void Range::set_value_no_signal(double p_val) {
if (shared->step > 0) {
p_val = Math::round(p_val / shared->step) * shared->step;
}
@@ -101,8 +110,6 @@ void Range::set_value(double p_val) {
}
shared->val = p_val;
-
- shared->emit_value_changed();
}
void Range::set_min(double p_min) {
@@ -267,6 +274,7 @@ void Range::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_page"), &Range::get_page);
ClassDB::bind_method(D_METHOD("get_as_ratio"), &Range::get_as_ratio);
ClassDB::bind_method(D_METHOD("set_value", "value"), &Range::set_value);
+ ClassDB::bind_method(D_METHOD("set_value_no_signal", "value"), &Range::set_value_no_signal);
ClassDB::bind_method(D_METHOD("set_min", "minimum"), &Range::set_min);
ClassDB::bind_method(D_METHOD("set_max", "maximum"), &Range::set_max);
ClassDB::bind_method(D_METHOD("set_step", "step"), &Range::set_step);