How can I detect if a Panel is being pressed? [Godot 3]

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By PugMasterPug
:warning: Old Version Published before Godot 3 was released.

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

do you want it on Node2D node?

volzhs | 2018-01-06 00:12

do I want what on Node2D node?

PugMasterPug | 2018-01-06 00:16

:bust_in_silhouette: Reply From: eons

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.

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)?

PugMasterPug | 2018-01-06 23:11

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.

eons | 2018-01-07 12:37