0 votes

Is there a way to check if a button is being hovered over? Because has_focus() and hover are not the same.

Thanks in advance!

in Engine by (72 points)

1 Answer

+4 votes

If you want to check this every frame or just query the state:


If you want to get notified when the button is hovered, you can use the signals mouse_enter and mouse_exit.

by (29,034 points)

That did the trick. Thanks :)

It is much better to access the signals.

Put the signal in the func _ready()

$MarginContainer/Menu/btn_NAME.connect("mouse_entered", self, "FUNCTION_NAME")

^ this will connect a signal to an action

$MarginContainer/Menu/btn_NAME is the path to button in the scene.

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 Frequently asked questions and 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 [email protected] with your username.