restore focus to keyboard input after 'optionbutton' selection

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

I have a screen with many different controls. I have the ‘N’ key set to open a note taking window. Normally it works fine, except when I try to hit ‘N’ after making a selection on a option button. After that selection, no keystrokes are noticed. I am assuming it is a focus issue. I have put around focus_owner = get_focus_owner() in a few places and then done:

func _on_StarListButton_focus_exited():

to try and restore focus to the keyboard. I even tried to

func _unhandled_input(event):

nothing seem to restore the ability to capture a keystroke? Any ideas?

:bust_in_silhouette: Reply From: codabase

I was looking up some info on this one, it looks like there’s also a release_focus() function. You might try setting up some type of signal or automation to release the focus on the button and then perhaps grab focus on the parent element or node you want to refocus.

Maybe this will be useful: How to remove focus from Control nodes? - Godot Forums

Hopefully this helps! Otherwise I could try to hop in and recreate the issue in Godot

Awesome! The code below did the trick. Thanks for the help!

func _unhandled_input(event):
	var current_focus_control = get_focus_owner()
	if current_focus_control:

grymjack | 2023-03-27 22:28