+1 vote

I am using the fileDialog to load in an image.
The file list is always empty when I show it with $FileDialog.show() (http://ictbram.com/godotQuestions/emptyFileList01.png)
The user has to press the refresh button to make the files appear (http://ictbram.com/godotQuestions/emptyFileList02afterRefresh.png )
Is there a way to do this by code?

in Engine by (32 points)
edited by

2 Answers

+1 vote
Best answer

There is: overload _draw() of FileDialog

func _draw():
    set_current_dir( path )
by (2,294 points)
selected by

ok, can this be done with gdscript? That's c++ probably? I meant, is there a way to do this by code with gdscript..

Sry, i meant "override". Actually, it is GDScript :)

aha thx, got it with a refresh function in extends FileDialog

func refresh(): 

func _draw():
    set_current_dir( "res://" )

I am not sure if this was the correct answer a while back but in 3.2 this does not work for me. use fileDialog.invalidate() instead.

+4 votes

Just in case anyone still wonders : the correct of displaying a FileDialog (like any popup) is to call the popup() function :

in this case, instead of $FileDialog.show(), just call $FileDialog.popup()

by (22 points)

While you are correct about the popup(), it does not solve the problem off having to click on refresh.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.