+2 votes

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

asked Jan 5, 2018 in Engine by PugMasterPug (117 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.

answered Jan 6, 2018 by eons (7,786 points)
selected Jan 6, 2018 by PugMasterPug

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


func _process(delta):
  if clicked:

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.