+2 votes

I have a Node2D, which contains a Panel, and I want to know when it is clicked.

in Engine by (123 points)

do you want it on Node2D node?

do I want what on Node2D node?

1 Answer

+2 votes
Best answer

Controls have a _gui_input (_input_event on 2.x) callback you can use to detect events on them, also as signal to pass to another node.

by (7,834 points)
selected by

How do I do it so that it is called while it is pressed (not only the frame it is pressed, but all frames it is actually pressed)?

Events trigger only when happen, and "hold" is not an event, but you can use the "press" to enable processing in _process

like

func _process(delta):
  if clicked:
    do_something()

Turn that variable false on the release event.

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.