Change the state of nodes inside a container

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

I have made a custom button: Custom button, TextureRect+labelScreenshot hosted at ImgBB — ImgBB
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?

:bust_in_silhouette: Reply From: Skyfrit

Try to set the mouse_filter for TextureRect and Label to Ignore.
And HBoxContainer mouse_filter to Stop.

enter image description here

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

david_Amlag | 2020-12-09 14:20