Touch persists outside of node. Is this a touch input bug or am I just a newb?

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

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??

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?

Ertain | 2019-06-07 20:44

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

Greg.game | 2019-06-08 01:30

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… : )

pferft | 2020-08-11 13:31

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.

Greg.game | 2021-02-12 20:34

Thanks for trying the engine.

Ertain | 2021-02-13 00:40

:bust_in_silhouette: Reply From: pferft

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!

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

Greg.game | 2021-08-10 05:43