2023-03-21 19:16:30 +00:00
|
|
|
extends TabContainer
|
|
|
|
|
|
|
|
|
|
var focus_list: Array
|
|
|
|
|
|
2026-01-22 15:21:12 +00:00
|
|
|
func _ready() -> void:
|
2023-03-21 19:16:30 +00:00
|
|
|
for child in get_children():
|
|
|
|
|
focus_list.append(_find_selectable_in(child))
|
|
|
|
|
|
2026-01-22 15:21:12 +00:00
|
|
|
func _find_selectable_in(parent:Control) -> Control:
|
2023-03-21 19:16:30 +00:00
|
|
|
if parent.focus_mode != FOCUS_NONE:
|
|
|
|
|
return parent
|
2026-01-22 15:21:12 +00:00
|
|
|
for child in parent.get_children():
|
|
|
|
|
var ret := _find_selectable_in(child)
|
|
|
|
|
if not ret == self:
|
2026-01-22 15:43:25 +00:00
|
|
|
return ret
|
2026-01-22 15:21:12 +00:00
|
|
|
return self
|
2023-03-21 19:16:30 +00:00
|
|
|
|
2026-01-22 15:21:12 +00:00
|
|
|
func _unhandled_input(event : InputEvent) -> void:
|
|
|
|
|
if event.is_action_type(): print_debug("Unhandled Input", event)
|
2023-03-21 19:16:30 +00:00
|
|
|
if event.is_action_type():
|
|
|
|
|
if event.is_action_pressed("ui_left"): previous()
|
|
|
|
|
elif event.is_action_pressed("ui_right"): next()
|
|
|
|
|
|
2026-01-22 15:21:12 +00:00
|
|
|
func next() -> void:
|
2023-03-21 19:16:30 +00:00
|
|
|
if current_tab < get_tab_count()-1:
|
|
|
|
|
if !Input.is_action_just_released("mouse_left"):
|
|
|
|
|
if not get_viewport().gui_get_focus_owner() == null:
|
|
|
|
|
focus_list[current_tab] = get_viewport().gui_get_focus_owner()
|
|
|
|
|
current_tab += 1
|
|
|
|
|
focus_list[current_tab].grab_focus()
|
|
|
|
|
else:
|
|
|
|
|
current_tab += 1
|
|
|
|
|
|
2026-01-22 15:21:12 +00:00
|
|
|
func previous() -> void:
|
2023-03-21 19:16:30 +00:00
|
|
|
if current_tab > 0:
|
|
|
|
|
if !Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT):
|
|
|
|
|
if not get_viewport().gui_get_focus_owner() == null:
|
|
|
|
|
focus_list[current_tab] = get_viewport().gui_get_focus_owner()
|
|
|
|
|
current_tab -= 1
|
|
|
|
|
focus_list[current_tab].grab_focus()
|
|
|
|
|
else:
|
|
|
|
|
current_tab -= 1
|
2026-01-22 15:43:25 +00:00
|
|
|
|
|
|
|
|
func notification(what: int, _reversed: bool = false) -> void:
|
|
|
|
|
if what == NOTIFICATION_VISIBILITY_CHANGED:
|
|
|
|
|
self.set_process_input(visible)
|