ScrollContainer's children event handling on Android

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Inqui

Currently, I’m creating a level menu where user should be able to choose the level to play. Nodes hierarchy:

-- Label
-- ScrollContainer
---- VBoxContainer
------ GridContainer1 (easy levels)
------ GridContainer2 (medium levels)
------ GridContainer3 (hard levels)

Each grid container has a bunch of buttons generated from this code:

    private static void SetLevels(in GridContainer container) {
    for (var i = 0; i < 50; i++) {
        var button = new Button {
            Text                = (i + 1).ToString(),
            SizeFlagsHorizontal = (int) SizeFlags.ExpandFill,
            SizeFlagsVertical   = (int) SizeFlags.ExpandFill,
            FocusMode           = FocusModeEnum.None,
            MouseFilter         = MouseFilterEnum.Pass

        button.Set("custom_fonts/font", ButtonFont);

        // Workaround for SetScript weird behaviour. See
        var iId = button.GetInstanceId();
        var completeButton = (Button) GD.InstanceFromId(iId);

And ButtonScript is a simple class with one connection:

internal class LevelButton: Button {
    public override void _Ready() {
        Connect("pressed", this, nameof(OnPressed));

    public void OnPressed() {
        GD.Print($"{Text}: pressed");

The problem is that on a mobile device (Android in my case) I cannot press any level button without high precision. In most cases, my touch will be detected as a scroll event (drag). PC doesn’t have such problem.

I’ve tried to change step and customStep in the VScrollBar instance from ScrollContainer and it works as expected but it doesn’t fix my problem.

My only guess would be to adjust the scroll_deadzone propery of the ScrollContainer. I would try to set it to something extraordinarily high like your screen size and see if you’re still having your problem.

timothybrentwood | 2021-05-03 18:55

Thanks! This is exactly what I need. I think I misunderstood the scroll_deadzone property.

Inqui | 2021-05-05 16:44

:bust_in_silhouette: Reply From: Inqui

As timothybrentwood said, there is a scroll_deadzone (or ScrollDeadzone in C#) property in the ScrollContainer node, which accepts some integer value (probably pixels). It is not documented at all, so it’s hard to understand the purpose of this property.