+1 vote

I'm using Godot 3.2.1.
I have a scene like this:
ScrollContainer(GridContainer(Many buttons))
I set the mouse_filter for the buttons and the grid to pass and ignore respectively, and I can scroll via touch on Android.
I can still click the buttons, but if I move my finger like 1 pixel away, it starts scrolling and stops the buttonpress. This makes interacting possible but annoying.
I got the idea (changing mouse_filter) from https://github.com/godotengine/godot/issues/21137
I'm using the default emulate mouse from touch.
Do you have any idea what I can do to make the button pressed until I move my finger like 10 pixels away?
Should I try to manipulate with the button's _gui_input()?

in Engine by (179 points)
edited by

1 Answer

+1 vote
Best answer

To answer my own question (for the people who read it later), I added a little script to the buttons to check manually (I have emulate mouse from touch enabled).

var pressdown_position = Vector2()
var press_threshold = 20

func _gui_input(event):
    if event is InputEventMouseButton and not disabled: #with InputEventTouch it didn't want to work well
        if event.pressed:
            pressdown_position = event.position
        elif event.position.distance_to(pressdown_position) <= press_threshold:
            _on_button_pressed() #call the function you want the buttonpress to call
by (179 points)
edited by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.

Categories