A Godot 4 ScrollContainer full of buttons does not scroll by touch until mouse emulation is on and the buttons pass the event

On the phone, none of my scrollable lists scrolled. A swipe over the campaign list did nothing; the same list scrolled fine with a mouse wheel on the desktop. Taps on the buttons inside the lists worked everywhere. It took two separate changes to make a finger drag scroll, and the second one is not where the first one led me to look.

TL;DR — ScrollContainer only drag-scrolls from emulated mouse events, so input_devices/pointing/emulate_mouse_from_touch must stay true; and a Button inside the list has mouse_filter = STOP by default, which swallows the press before the container can start a drag — set the list’s buttons to MOUSE_FILTER_PASS.

The setup

A small Android game built with Godot 4.7.1, all UI in Control nodes. Three screens are vertical lists: a ScrollContainer holding a VBoxContainer of rows, each row an HBoxContainer with labels and one Button (88 px tall, so that fingers can hit it). The battle screen handles touches itself in _unhandled_input by reacting to InputEventScreenTouch only. To keep that path « touch only », I had set both emulation flags off in project.godot:

[input_devices]
pointing/emulate_touch_from_mouse=true   ; desktop clicks become touches
pointing/emulate_mouse_from_touch=false  ; touches never become mouse events

Lists were built in code; buttons had no explicit mouse_filter.

What I expected

Godot 4’s ScrollContainer documents drag-to-scroll on touch screens, and the buttons received taps, so I assumed touch events reached the whole tree. My mental model was « touch is a first-class input, mouse emulation is only a desktop convenience ».

What actually happens

With adb shell input swipe on the emulator, the list did not move at all. Switching emulate_mouse_from_touch back to true changed nothing visible. A reviewer then reproduced the two states in a windowed build by injecting events and reading scroll_vertical after a synthetic drag:

  • emulation off, buttons default: scroll_vertical = 0
  • emulation on, buttons STOP (default): scroll_vertical = 0, pressed never fired either (the drag cancelled the press, but nothing scrolled)
  • emulation on, buttons PASS: scroll_vertical = 165, pressed count 0 — the drag scrolled and correctly cancelled the button

A plain tap on a PASS button still fires pressed exactly once (button_down 1, pressed 1), inside and outside a ScrollContainer.

Three panels: with mouse emulation off the drag never reaches ScrollContainer; with emulation on but STOP buttons the button consumes it; with emulation on and PASS buttons the container scrolls 165 px and cancels the press

The fix

Two lines. First the project setting:

[input_devices]
pointing/emulate_touch_from_mouse=true
pointing/emulate_mouse_from_touch=true

Then every button that lives inside a scrollable list:

var btn := Button.new()
btn.text = "Play"
btn.custom_minimum_size = Vector2(160, 88)
btn.mouse_filter = Control.MOUSE_FILTER_PASS  # let the drag reach ScrollContainer
row.add_child(btn)

Buttons outside lists can keep the default. Nothing else changed: the battle screen still reacts only to InputEventScreenTouch, and one tap still produces one deploy — the emulated mouse events it receives are simply ignored by the is InputEventScreenTouch check.

Why it works

ScrollContainer::gui_input starts a drag on InputEventMouseButton and moves it on InputEventMouseMotion. It never looks at InputEventScreenTouch or InputEventScreenDrag. On a touch screen those mouse events exist only because the viewport synthesises them from touches — which is what emulate_mouse_from_touch controls. Turn it off and the container is deaf.

The second lock is the GUI event routing. Viewport::_gui_call_input delivers a pointer event to the deepest control under the pointer and walks up the parents until one of them has mouse_filter = STOP. A Button is STOP by default, so a press that starts on a button ends there; the ScrollContainer above never sees the press that would begin a drag. With PASS, the button gets the press and the container gets it too; when the container decides the finger moved far enough, it sends NOTIFICATION_SCROLL_BEGIN down the tree and BaseButton cancels its pending press, so scrolling over a button does not activate it.

Taps on a PASS button also fall through to _unhandled_input of the scene. That was harmless here because the list sat outside the game grid, but a screen that mixes a pass-through list and a touch-driven world needs an explicit guard (test the touch position against the list’s global rect and return).

What I did not test

Godot 4.7.1 only, GL Compatibility renderer, Android 14 x86_64 emulator and a desktop Linux window with injected events. I did not try ScrollContainer with follow_focus or with nested scroll containers, nor iOS. I also kept gui/common/default_scroll_deadzone at 8; a different deadzone changes how far a finger must travel before a press turns into a scroll.

Facts

context: Godot 4.7.1 Control UI on Android, lists built from ScrollContainer + Button rows
problem: finger drag does not scroll the list although taps on the buttons work
solution: emulate_mouse_from_touch=true in project settings AND mouse_filter=PASS on the buttons inside the list
verified_on: 2026-09-12
applies_to: Godot 4.7.1, Android (emulator and touch screens), GL Compatibility
does_not_apply_to: mouse-wheel scrolling on desktop (works regardless); iOS untested

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Retour en haut