@@ -171,9 +171,11 @@ void ScrollContainer::gui_input(const Ref<InputEvent> &p_gui_input) {
171171 bool h_scroll_enabled = horizontal_scroll_mode != SCROLL_MODE_DISABLED ;
172172 bool v_scroll_enabled = vertical_scroll_mode != SCROLL_MODE_DISABLED ;
173173
174+ int event_device_id = p_gui_input->get_device ();
175+
174176 Ref<InputEventMouseButton> mb = p_gui_input;
175177
176- if (mb.is_valid ()) {
178+ if (mb.is_valid () && event_device_id != InputEvent:: DEVICE_ID_EMULATION ) {
177179 if (mb->is_pressed ()) {
178180 bool scroll_value_modified = false ;
179181 bool swap_axes = scroll_horizontal_by_default != mb->is_shift_pressed ();
@@ -225,17 +227,12 @@ void ScrollContainer::gui_input(const Ref<InputEvent> &p_gui_input) {
225227 return ;
226228 }
227229 }
230+ return ;
231+ }
228232
229- bool is_touchscreen_available = DisplayServer::get_singleton ()->is_touchscreen_available ();
230- if (!is_touchscreen_available) {
231- return ;
232- }
233-
234- if (mb->get_button_index () != MouseButton::LEFT ) {
235- return ;
236- }
237-
238- if (mb->is_pressed ()) {
233+ Ref<InputEventScreenTouch> touch = p_gui_input;
234+ if (touch.is_valid () && event_device_id != InputEvent::DEVICE_ID_EMULATION ) {
235+ if (touch->is_pressed ()) {
239236 if (drag_touching) {
240237 _cancel_drag ();
241238 }
@@ -253,7 +250,7 @@ void ScrollContainer::gui_input(const Ref<InputEvent> &p_gui_input) {
253250
254251 } else {
255252 if (drag_touching) {
256- if (drag_speed == Vector2 ()) {
253+ if (touch-> is_canceled () || drag_speed == Vector2 ()) {
257254 _cancel_drag ();
258255 } else {
259256 drag_touching_deaccel = true ;
@@ -263,11 +260,11 @@ void ScrollContainer::gui_input(const Ref<InputEvent> &p_gui_input) {
263260 return ;
264261 }
265262
266- Ref<InputEventMouseMotion> mm = p_gui_input;
263+ Ref<InputEventScreenDrag> drag = p_gui_input;
267264
268- if (mm .is_valid ()) {
265+ if (drag .is_valid () && event_device_id != InputEvent:: DEVICE_ID_EMULATION ) {
269266 if (drag_touching && !drag_touching_deaccel) {
270- Vector2 motion = mm ->get_relative ();
267+ Vector2 motion = drag ->get_relative ();
271268 drag_accum -= motion;
272269
273270 if (beyond_deadzone || (h_scroll_enabled && Math::abs (drag_accum.x ) > deadzone) || (v_scroll_enabled && Math::abs (drag_accum.y ) > deadzone)) {
0 commit comments