how to detect label click

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

there is a label that i want to use as a button
how do i connect label click event into script function?

:bust_in_silhouette: Reply From: rakkarage
extends Control

func _input(event: InputEvent) -> void:
	if event is InputEventMouseButton and event.pressed and event.button_index == BUTTON_RIGHT:
		var bounds = Rect2(rect_position, rect_size)
		if bounds.has_point(event.position):

doesnt work
where to put this code?

lxknvlk | 2020-11-07 18:28

on label, right click

rakkarage | 2020-11-07 21:12

1 Like
:bust_in_silhouette: Reply From: Skyfrit

1.Set the label mouse_filter to stop or pass.
2.Connect gui_input signal.
3.Put those code into script

func _on_Label_gui_input(event):
if (event is InputEventMouseButton && event.pressed && event.button_index == 1):