Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

[ScrollBar] Fix drag scrolling interfering with mouse on touchscreen

Anish Kumar610a1f416cd7
diff --git a/scene/gui/scroll_bar.cpp b/scene/gui/scroll_bar.cpp
index c4ab2ca82c3..1a97c9ecca2 100644
--- a/scene/gui/scroll_bar.cpp
+++ b/scene/gui/scroll_bar.cpp
@@ -583,19 +583,19 @@ void ScrollBar::_drag_node_input(const Ref<InputEvent> &p_input) {
return;
}
- Ref<InputEventMouseButton> mb = p_input;
+ if (p_input->get_device() == InputEvent::DEVICE_ID_EMULATION) {
+ return;
+ }
- if (mb.is_valid()) {
- if (mb->get_button_index() != MouseButton::LEFT) {
- return;
- }
+ Ref<InputEventScreenTouch> touch = p_input;
- if (mb->is_pressed()) {
+ if (touch.is_valid()) {
+ if (touch->is_pressed()) {
drag_node_speed = Vector2();
drag_node_accum = Vector2();
last_drag_node_accum = Vector2();
drag_node_from = Vector2(orientation == HORIZONTAL ? get_value() : 0, orientation == VERTICAL ? get_value() : 0);
- drag_node_touching = DisplayServer::get_singleton()->is_touchscreen_available();
+ drag_node_touching = true;
drag_node_touching_deaccel = false;
time_since_motion = 0;
@@ -617,11 +617,11 @@ void ScrollBar::_drag_node_input(const Ref<InputEvent> &p_input) {
}
}
- Ref<InputEventMouseMotion> mm = p_input;
+ Ref<InputEventScreenDrag> s_drag = p_input;
- if (mm.is_valid()) {
+ if (s_drag.is_valid()) {
if (drag_node_touching && !drag_node_touching_deaccel) {
- Vector2 motion = mm->get_relative();
+ Vector2 motion = s_drag->get_relative();
drag_node_accum -= motion;
Vector2 diff = drag_node_from + drag_node_accum;