0 votes

Any way to identify the actual focused item via gdscript?

Godot version 3.4.2
in Engine by (33 points)

1 Answer

+1 vote
Best answer

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():
by (95 points)
selected by
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.