diff --git a/RetroWindowsGUI/DesktopWindow.gd b/RetroWindowsGUI/DesktopWindow.gd index f50b428..dc39e13 100755 --- a/RetroWindowsGUI/DesktopWindow.gd +++ b/RetroWindowsGUI/DesktopWindow.gd @@ -7,13 +7,31 @@ extends Control var windowed_rect: Rect2 -func _input(event: InputEvent): +func get_descendants(node: Node) -> Array[Node]: + var nodes: Array[Node] = [] + + for child in node.get_children(): + if child.get_child_count() > 0: + nodes.append(child) + nodes.append_array(get_descendants(child)) + else: + nodes.append(child) + + return nodes + +func _ready() -> void: + for descendant in get_descendants(self): + descendant.gui_input.connect(_gui_input) + +func _gui_input(event: InputEvent) -> void: if event is InputEventMouseButton: if event.pressed: if get_global_rect().has_point(get_global_mouse_position()): desktop.current_window = self get_parent().move_child(self, get_parent().get_child_count()) - elif event is InputEventKey: + +func _input(event: InputEvent): + if event is InputEventKey: if event.keycode == KEY_F11: if event.pressed: if desktop.current_window == self: