+2 votes

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

in Engine by (72 points)

2 Answers

0 votes
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):
by (1,672 points)

doesnt work
where to put this code?

on label, right click

+2 votes

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):
by (598 points)
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.