How do you get the child nodes at runtime/remote of a built in such as FileDialog?

Godot Version

4

Question

When I try to get the child nodes of FileDialog, I get an empty array. In the image you can see when I click the Remote in the scene tree there are other child nodes that are accessible individually. How can I get a list of these nodes. This is the code I use.

extends FileDialog
var default_dir = "."
var dir_picker: FileDialog
var view_port: Window

func _ready():
	dir_picker=self
	#"FileDialog/@VBoxContainer@10/@HBoxContainer@27/@Button@26"
	$"./@ConfirmationDialog@79".always_on_top=true
	$"./@ConfirmationDialog@79".visible=true
	var parent=get_node(^".")
	var node_list=parent.get_children()	
	pass

Is this just getting self or the parent (Main)?

Anyway there is a parameter for get_children(include_internal=false) if the file dialogue is a scene, then it’s children for the scene are considered internal.

Try get_children(true)

1 Like

Thanks, that works. I am just trying to fix a bug in FileDialog where Confirmations such as Create Folder are not Modal and if you click away they hide behind the main window.

I don’t know if it is possible to trust the random names used to generate the hidden nodes.

func fix_confirmations(this: FileDialog):
	var node_list=this.get_children(true)	
	for node in node_list:
		if node.is_class("ConfirmationDialog"):
			node.always_on_top=true

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.