extends Panel

var prev_focus

func open():
	show()
	prev_focus = get_focus_owner()
	mitigate_ui_navigation_spill_over(true)
	$"VBoxContainer/SaveNQuit".grab_focus()

func mitigate_ui_navigation_spill_over(var value: bool):
	var mode = Control.FOCUS_NONE if value else Control.FOCUS_ALL
	$"%ProfilesMenu".focus_mode = mode
	$"%Back".focus_mode = mode
	$"%Reset".focus_mode = mode
	$"%Save".focus_mode = mode
	for line in $"../KeymapViewer/ScrollContainer/ActionKeyList".get_children():
		line.get_node("ChangeButton").focus_mode = mode

func close():
	hide()
	mitigate_ui_navigation_spill_over(false)
	self.release_focus()
	prev_focus.grab_focus()
