[SOLVED]How to refresh the filelisting with FileDialog?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By ictbram

I am using the fileDialog to load in an image.
The file list is always empty when I show it with $FileDialog.show() (

)
The user has to press the refresh button to make the files appear ( )
Is there a way to do this by code?

:bust_in_silhouette: Reply From: hilfazer

There is: overload _draw() of FileDialog

func _draw():
	set_current_dir( path )

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

ictbram | 2018-05-24 16:53

Sry, i meant “override”. Actually, it is GDScript :slight_smile:

hilfazer | 2018-05-24 17:18

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

func refresh():	
	self._draw()
	
func _draw():
	set_current_dir( "res://" )

ictbram | 2018-05-24 17:49

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.

Ram | 2020-08-25 12:16

:bust_in_silhouette: Reply From: Cevantime

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()

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

Ram | 2020-08-25 12:13

Actually it does, for me

rocket 007 | 2023-06-11 07:47