–1 vote

I have the button (control). The button uses the custom style, making it highlighted when pressed (the highlight is created by the Focus texture option of the Custom Styles in the Inspector of the button node).
It works when I physically press the button. It gets highlighted and highlighting lasts until another button is pressed.
But I wanted it to be/look already highlighted when the scene starts - before anything is pressed.
So far I tried to put in the func _ready():

  • $Control/Button.emit_signal("pressed")
  • $Control/Button.emit_signal("focus_entered")
  • $Control/Button.set_pressed(true)
  • $Control/Button.pressed = true

but at the start of the scene the button always stays in his default, non-highlighted appearance. However

func _on_button_pressed():
     print("Button pressed") 

seams to execute at the scene start, as there is "Button pressed" message in the output console - at least with $Control/Button.emit_signal("pressed") in func _ready():

Any idea how to be/make it look according to settings in Focus Custom Style at the very start of the scene?

in Engine by (719 points)
retagged by

1 Answer

+1 vote
Best answer

Check out the documentation on Control-nodes. What you seek is:

func _ready():
by (10,391 points)
selected by

Thank you njamster . grab_focus() is exactly what I needed.

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 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 webmaster@godotengine.org with your username.