Check if Button is being hovered over

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

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!

:bust_in_silhouette: Reply From: Zylann

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

button.is_hovered()

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

That did the trick. Thanks :slight_smile:

Chain | 2017-08-31 12:55

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.

Speart | 2020-11-12 16:21