diff options
author | metamuffin <metamuffin@disroot.org> | 2024-07-01 18:03:13 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-07-01 18:03:13 +0200 |
commit | 9f191b0dff157ca8e038ed26b62fb5eac8e79b57 (patch) | |
tree | a34f4ee4ecbdfd9029fdd6f76512d2d77e90c69d | |
parent | d88e391561fd0cc8a29558aad35a5160d3f5813e (diff) | |
download | hurrycurry-9f191b0dff157ca8e038ed26b62fb5eac8e79b57.tar hurrycurry-9f191b0dff157ca8e038ed26b62fb5eac8e79b57.tar.bz2 hurrycurry-9f191b0dff157ca8e038ed26b62fb5eac8e79b57.tar.zst |
restore focus after submenu close
-rw-r--r-- | client/global.gd | 2 | ||||
-rw-r--r-- | client/menu/menu.gd | 2 |
2 files changed, 4 insertions, 0 deletions
diff --git a/client/global.gd b/client/global.gd index fdb4df28..4ea07a4f 100644 --- a/client/global.gd +++ b/client/global.gd @@ -60,8 +60,10 @@ func _init(): update_fullscreen() update_language() +var focused_node: Control func _ready(): get_viewport().gui_focus_changed.connect(Sound.play_hover_maybe) + get_viewport().gui_focus_changed.connect(func (node): focused_node = node) func _input(_event): if Input.is_action_just_pressed("fullscreen"): diff --git a/client/menu/menu.gd b/client/menu/menu.gd index 5e7ba34c..2c539bd9 100644 --- a/client/menu/menu.gd +++ b/client/menu/menu.gd @@ -34,6 +34,7 @@ func menu_anim_cover(state: bool): var popup: Menu = null func submenu(path: String, instant: bool = false): + var prev_focus = Global.focused_node if popup != null: return await menu_anim_cover(true) popup = load(path).instantiate() @@ -43,6 +44,7 @@ func submenu(path: String, instant: bool = false): await submenu_close print("Submenu closed ", path) await menu_anim_cover(false) + if prev_focus != null: prev_focus.grab_focus() func exit(): await self.menu_anim_exit() |