@@ -55,7 +55,7 @@ func _ready():
5555
5656 # Try to find a focus node if one was not specified
5757 if not current_focus or not current_focus .is_visible_in_tree ():
58- current_focus = _find_focusable (parent .get_children (), parent )
58+ current_focus = find_focusable (parent .get_children (), parent )
5959
6060
6161## Recalculate the focus neighbors of the container's children
@@ -118,7 +118,7 @@ func grab_focus() -> void:
118118 if not is_focused ():
119119 focus_stack .push (self )
120120 if not current_focus :
121- current_focus = _find_focusable (parent .get_children (), parent )
121+ current_focus = find_focusable (parent .get_children (), parent )
122122 logger .trace ("Found focus node: " + str (current_focus ))
123123 if current_focus :
124124 logger .info (parent .name + " grabbing focus on node: " + current_focus .name )
@@ -225,7 +225,8 @@ func _find_child_focus_group(nodes: Array[Node], root: Node = null) -> FocusGrou
225225
226226
227227# Recursively searches the given node children for a focusable node.
228- func _find_focusable (nodes : Array [Node ], root : Node = null ) -> Node :
228+ static func find_focusable (nodes : Array [Node ], root : Node = null ) -> Node :
229+ var logger := Log .get_logger ("FocusGroup" , Log .LEVEL .INFO )
229230 if nodes .size () == 0 :
230231 logger .trace ("Node has no children to check." )
231232 return null
@@ -236,7 +237,7 @@ func _find_focusable(nodes: Array[Node], root: Node = null) -> Node:
236237 # If the node is not a Control, try to find a child control node
237238 if not node is Control :
238239 logger .trace ("Node not control. Checking children." )
239- focusable = _find_focusable (node .get_children (), root )
240+ focusable = find_focusable (node .get_children (), root )
240241 if focusable :
241242 return focusable
242243 logger .trace ("Node: " + node .name + " has no more children to check." )
@@ -254,7 +255,7 @@ func _find_focusable(nodes: Array[Node], root: Node = null) -> Node:
254255 return node
255256 # Otherwise try and recursively find a child that can be focused
256257 logger .trace ("Node: " + node .name + " is not focusable. Checking its children." )
257- focusable = _find_focusable (node .get_children (), root )
258+ focusable = find_focusable (node .get_children (), root )
258259 if focusable :
259260 return focusable
260261 logger .trace ("Node has no focusable children." )
0 commit comments