+2 votes

how to simulate a double click mouse button?
Needs a timer?

in Engine by (1,469 points)

2 Answers

+5 votes
Best answer
func _ready():
    get_node("Button").connect("input_event", self, "on_input")

func on_input(ev):
    if ev.type==InputEvent.MOUSE_BUTTON and ev.is_pressed() and ev.doubleclick:
        print("double clicked !")
by (9,742 points)
selected by

this works for all mouse buttons.
If I want work on a specific button? For example only for left button?

then add ev.button_index==1 too.

Thanks. It Works!
Is there anyway to simulate long press click?
Thanks a lot.

+1 vote

You have to warp the InputEvent and then check if it is a InputEventMouseButton. Then you can test if it is a double click:

func _ready():

func _input(event):
    if event.type==InputEvent.MOUSE_TYPE
        if event.doubleclick:
            print("double click pressed")

Read this too.

by (683 points)
edited 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 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.