Simulate Click

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

To simulate a totally real click, is it enough to use the javascript .click() method?
Or do I have to dispatch the click event?
Or what can I do?

:bust_in_silhouette: Reply From: njamster

Javascript isn’t among the languages officially supported by Godot. If your question is about faking a mouse click event in Godot, the (GDScript-)answer would be:

var fake_input = InputEventMouseButton.new()
fake_input.button_index = BUTTON_LEFT
fake_input.doubleclick = false
fake_input.pressed = true
get_tree().input_event(fake_input)