0 votes


how can I handle click and doubleclick on the same node different?

extends Area2D

func _on_MouseClick_input_event(viewport, event, shape_idx):
    if event is InputEventMouseButton and event.doubleclick:
    elif event is InputEventMouseButton and event.pressed:

Each time I do one doubleclick on the node the output in the log is:

in Engine by (25 points)

I had kind of same issue. I needed to know if the user did a single click or a double click.

My solution was this:

var LastPressedTime = 0

func _process(delta):
    if (LastPressedTime > 0):
        LastPressedTime = max(0, LastPressedTime - delta)
        if (LastPressedTime == 0):

func _input(event):
    if event is InputEventMouseButton and event.pressed:
        if (event.button_index == BUTTON_WHEEL_UP || event.button_index == BUTTON_WHEEL_DOWN):
            if (LastPressedTime > 0):
                LastPressedTime = 0
                LastPressedTime = 0.4

func OnDoubleClick(position):
    print("double: "+str(position.x)+","+str(position.y))

func OnSingleClick(position):
    print("single: "+str(position.x)+","+str(position.y))

1 Answer

+1 vote
Best answer

This is right. Take selecting folders as an example, the first click selects it and if the second click is within the time limit for a double click it opens, thus the log would print single, double and clicking too slowly will print single, single.

by (3,247 points)
selected 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 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.