change color of text when focus

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

Any way to identify the actual focused item via gdscript?

:bust_in_silhouette: Reply From: haha-lolcat1

there are multiple ways of doing this.

if you are using a Button node, you can simply set the “normal” look and the “focused” look in the textures property.

another cool thing about control nodes, such as Button, is that you can change the text focus in themes without gdscript.
Select the desired node, go to Theme Overrides in its properties, enable Font Color Focus and set the desired color.
this might be what you are looking for.

otherwise you can use the existing focus_entered() signal and gdscript and connect it to itself.

func _on_some_node_focus_entered():
	modulate = Color(2,2,2,2)

func _on_some_node_focus_exited():
	modulate = Color(1,1,1,1) #to bring it back to normal

by the way, to identify a node that is currently in focus, you can do get_focus_owner()
for example if the signal is connected to a parent node:

func _on_some_node_focus_entered():