0 votes

I know we're supposed to report bugs on GitHub, but I'm a newb so want to make sure I'm not just newbing out.

I have a Control node with the following script inside it:

func _gui_input(event):
if event is InputEventScreenTouch:
    print("Screen was touched!")
    node0.play_sound()

When I touch the control, the sound is played. When I lift my finger the sound is played again. That all seems right. However if I touch the control (sound played), keep my finger pressed to the screen, and then move it outside the control before lifting it, the sound is still played again even though I am outside the bounds of the control.

When using the mouse on my computer using similar mouse input logic, these boundaries are respected no problem.

This isn't the only inconsistency I've found between mouse and touch control, but this seems like it may be a concrete bug that could lead to some farther reaching improvements if fixed.

InputEventScreenDrag acts similarly (it keeps triggering even outside the node until I lift my finger).

Should I report this you think??

in Engine by (14 points)

I'm not 100% sure, but InputEventScreenTouch may report touchscreen events even when you tap off the node. Maybe you could rewrite it to use the _input() function? Maybe things would be different?

Thanks but _input is too generic. Need it handled by a control. Tried _input but led to nonstop triggering.

Hey Greg.game, me being a newb as well I've been trying to find a solution to exactly this problem since weeks by now, to no avail. Have you been successful in the meantime?

It appears there are one or two tweaks concerning buttons (and especially on touch screens) that are, just like this one, just not covered properly yet. I'm dreaming of a full-fledged touch screen button functionality line-up to fulfill all needs and wishes... *: )*

Sadly I gave up on Godot because of this. If it's fixed I might pick my project back up, but that bug really put a damper on it.

Thanks for trying the engine.

1 Answer

+1 vote

Reaching the chapter "buttons" when starting with Godot (and I'm still a beginner!), I tried the built-in buttons (everything aimimg for touch-devices), wasn't satisfied and therefor attempted to build my own ones with Area2D, CollisionShapes and some code.

I wanted several behaviours like auto-cancelling when holding down for some time (so no release) and sliding the finger off the button to cancel as well while a neighbouring button should not react when sliding on at the same time, things like that. And in the end I succeeded with all kinds of hacky things like

    func _on_Button1Area_input_event(_viewport, _event, _shape_idx):
        if Input.is_action_just_pressed("mousebuttonclick"):
            ignore_release = false
            ignore_tap = false
            ignore_slide
    if Input.is_action_just_released("mousebuttonclick"):
            ignore_tap = true

    func _on_Button1Area_mouse_exited():
...

    func _on_Button1Area_mouse_entered():
        ignore_release = true
        ignore_tap = true
        ignore_slide = true
        return

but first and foremost setting up input_pickable = true or = false all over the place...

Until I realized that one majour thing coming up next wouldn't work with that setup: placing my button behind a "stop-input" label to have it not react when tapped worked fine, but it turned out that my buttons (so my CollisionShapes) in front of the label didn't recognize input as well in that case - which rendered the whole thing useless for me.

But: the bulit-in buttons actually do react as they should, so I basically went back to formula and started hacking these on-board buttons like I did my own before.

I'm not sure if all this is helpful for you, but somehow I was able to tweak the button-control nodes to my liking using this kind of functions-variables-setup. I'm still building my own "pretty" butons on top of the "real" ones, and I didn't stumble over any problematic situation since.

Good luck with your project!

by (365 points)

Thanks for the detailed response! I might pick up my project again and try some of this.

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.