Android Touch Problem - One tap triggers mouse_entered signal, second tap triggers _input(InputEventMouseButton)

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


I made a game that I want to release on Android.

In my game, I have a Control node that listens for the mouse_entered and mouse_exited signals.

extends Control

signal pressed()

var mouse_inside = false

func _ready():
    connect("mouse_entered", self, "_on_mouse_entered")
    connect("mouise_exited", self, "_on_mouse_exited")

func _input(event):
    if event is InputEventMouseButton:
        if event.pressed \
                and event.button_index == BUTTON_LEFT \
                and self.mouse_inside:

func _on_mouse_entered():
    self.mouse_inside = true

func _on_mouse_exited():
    self.mouse_inside = false

On Android this code behaves very strangely. When I tap the Control, I receive the mouse_entered signal. When I tap it again, I receive the InputEventMouseButton event.

Why is this the case? Is there some setting related to this?
I am using Godot v3.5.1 Non-C#

:bust_in_silhouette: Reply From: Juxxec

To anybody who might run into this problem. This issue occurs only when using the _input(event) method. When I switched to using the _gui_event(event) method, now the touch works as expected.

Additionally, the _gui_input(event) is called when the mouse is inside the Control, which is exactly what I wanted to detect the press.

Enable Touch From Mouse Project Setting

Also, I had to go into the Project Settings and enabled Enable Touch from Mouse, but I don’t think that had anything to do with it.

My code now looks like this:

func _gui_input(event):
    if event is InputEventMouseButton:
        if event.pressed \
                    and event.button_index == BUTTON_LEFT: