0 votes

I have made a custom button: Custom button, TextureRect+label -> https://ibb.co/0DTh0vs
And I want to make it 2 status active and desactive (that change the text colour). The code that i attach to "HBoxContainer" Node is the next one:

func activate() -> void:
    modulate = activateColor

func desactivate() -> void:
    modulate = desactivateColor

func _on_mouse_entered() -> void:
    print("mouse enter the button")
    emit_signal("mouse_over_button", rect_position.y - rect_size.y/2)

func _on_mouse_left() -> void:
    print("mouse left the button")

But this only work when the mouse cursor is directly touching the HBoxContainer node and don't work when is on the icon or the text and I want to works on all the surface of the button.

Any ideas?

in Engine by (19 points)
edited by

1 Answer

0 votes
Best answer

Try to set the mousefilter for TextureRect and Label to Ignore.
And HBoxContainer mouse
filter to Stop.

enter image description here

by (614 points)
selected by

Ladies and gentlemen, we have a winner :)
It works, thanks.

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.