0 votes


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#

Godot version 3.5.1
in Engine by (246 points)
edited by

1 Answer

0 votes
Best answer

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:
by (246 points)
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 Frequently asked questions and 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 [email protected] with your username.