defensive get_locale + focus tab strip when options menu becomes visible
get_locale() now falls back to TranslationServer.get_locale() if the locale key is missing from _state, avoiding a crash when the options autoload hasn't run _ready yet (e.g. another autoload triggers it during its own _ready). When the options menu becomes visible, focus moves to the TabContainer so keyboard/gamepad navigation between tabs works without a click. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
058bb91383
commit
845e155719
|
|
@ -17,7 +17,7 @@ func _ready():
|
||||||
TranslationServer.set_locale(_state[_KEY_LOCALE])
|
TranslationServer.set_locale(_state[_KEY_LOCALE])
|
||||||
|
|
||||||
func get_locale() -> String:
|
func get_locale() -> String:
|
||||||
return _state[_KEY_LOCALE]
|
return _state.get(_KEY_LOCALE, TranslationServer.get_locale())
|
||||||
|
|
||||||
func set_locale(locale: String) -> void:
|
func set_locale(locale: String) -> void:
|
||||||
_state[_KEY_LOCALE] = locale
|
_state[_KEY_LOCALE] = locale
|
||||||
|
|
|
||||||
|
|
@ -17,4 +17,9 @@ func _on_back_button_pressed() -> void:
|
||||||
|
|
||||||
func _on_visibility_changed() -> void:
|
func _on_visibility_changed() -> void:
|
||||||
if visible:
|
if visible:
|
||||||
grab_focus()
|
# Defer one frame so the TabContainer is laid out and focusable before
|
||||||
|
# we call grab_focus on it.
|
||||||
|
await get_tree().process_frame
|
||||||
|
var tabs := find_child("TabContainer")
|
||||||
|
if tabs is Control:
|
||||||
|
(tabs as Control).grab_focus()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue