summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2022-01-07 13:02:40 +0100
committerGitHub <noreply@github.com>2022-01-07 13:02:40 +0100
commit7640dc2c73478bb340529e91a3da2ed0600db34f (patch)
treec88f8894cf0f4dc4b7bf52b77919142e03a23d12 /scene/gui
parentfaa47636887b4c4637a36c37309fcc1d6f29251c (diff)
parent753ae7403fb333f6b2edf44ddae1d67135ed9e28 (diff)
Merge pull request #55775 from timothyqiu/slider-drag
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/slider.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/scene/gui/slider.cpp b/scene/gui/slider.cpp
index 7d07299d88..1d459d589f 100644
--- a/scene/gui/slider.cpp
+++ b/scene/gui/slider.cpp
@@ -70,8 +70,13 @@ void Slider::gui_input(const Ref<InputEvent> &p_event) {
}
grab.active = true;
grab.uvalue = get_as_ratio();
+
+ emit_signal(SNAME("drag_started"));
} else {
grab.active = false;
+
+ const bool value_changed = !Math::is_equal_approx((double)grab.uvalue, get_as_ratio());
+ emit_signal(SNAME("drag_ended"), value_changed);
}
} else if (scrollable) {
if (mb->is_pressed() && mb->get_button_index() == MouseButton::WHEEL_UP) {
@@ -264,6 +269,9 @@ void Slider::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_scrollable", "scrollable"), &Slider::set_scrollable);
ClassDB::bind_method(D_METHOD("is_scrollable"), &Slider::is_scrollable);
+ ADD_SIGNAL(MethodInfo("drag_started"));
+ ADD_SIGNAL(MethodInfo("drag_ended", PropertyInfo(Variant::BOOL, "value_changed")));
+
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "editable"), "set_editable", "is_editable");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "scrollable"), "set_scrollable", "is_scrollable");
ADD_PROPERTY(PropertyInfo(Variant::INT, "tick_count", PROPERTY_HINT_RANGE, "0,4096,1"), "set_ticks", "get_ticks");