Fix main menu focus
This commit is contained in:
@@ -41,7 +41,7 @@ func _unhandled_input(event:InputEvent) -> void:
|
||||
if event.is_action_pressed("menu"):
|
||||
if visible:
|
||||
close()
|
||||
elif !UI.dialogueActive:
|
||||
elif !UI.dialogueActive and SCENE.currentScene == SceneSingleton.SceneType.OVERWORLD:
|
||||
open()
|
||||
get_viewport().set_input_as_handled()
|
||||
return
|
||||
|
||||
@@ -12,7 +12,10 @@ func _ready() -> void:
|
||||
btnQuit.pressed.connect(_onQuitPressed)
|
||||
settingsMenu.opened.connect(_onSettingsOpened)
|
||||
settingsMenu.closed.connect(_onSettingsClosed)
|
||||
btnNewGame.grab_focus()
|
||||
|
||||
func _notification(what:int) -> void:
|
||||
if what == NOTIFICATION_ENTER_TREE:
|
||||
btnNewGame.call_deferred("grab_focus")
|
||||
|
||||
func _onSettingsOpened() -> void:
|
||||
# Move focus into the settings panel so the controller can navigate it.
|
||||
|
||||
@@ -52,6 +52,8 @@ func onTabChanged(tabIndex:int) -> void:
|
||||
_focusFirstIn(tabControls[tabIndex])
|
||||
|
||||
func _focusFirstIn(container:Control) -> void:
|
||||
if !is_visible_in_tree():
|
||||
return
|
||||
for child in container.get_children():
|
||||
if child is Control and child.focus_mode != Control.FOCUS_NONE:
|
||||
child.grab_focus()
|
||||
|
||||
Reference in New Issue
Block a user