24 lines
621 B
GDScript
24 lines
621 B
GDScript
extends TabContainer
|
|
|
|
var stolen_focus : Control
|
|
|
|
func _ready() -> void:
|
|
get_viewport().gui_focus_changed.connect(on_focus_changed)
|
|
visibility_changed.connect(on_visibility_changed)
|
|
func _exit_tree() -> void:
|
|
get_viewport().gui_focus_changed.disconnect(on_focus_changed)
|
|
|
|
func _on_quit_button_pressed() -> void:
|
|
visible = false
|
|
$ChannelPlayer.call("Play")
|
|
|
|
func on_visibility_changed():
|
|
if visible:
|
|
await get_tree().process_frame
|
|
$plants/SeedpacketsContainer/GridContainer.get_child(0).grab_focus()
|
|
else:
|
|
stolen_focus.grab_focus()
|
|
|
|
func on_focus_changed(to : Control):
|
|
if visible: return
|
|
stolen_focus = to
|