0 votes

The documentation states that the on_FileDialog_file_selected() signal should fire only after the OK button is pressed or a file is double-clicked:
Event emitted when the user selects a file (double clicks it or presses the OK button).
However, when I click on a file the FileDialog disappears and the clicked file is not selected until I open the FileDialog a second time.
The code successfully loads and saves but I have to open the FileDialog twice for every operation.
Full project on Github

func _on_SaveButton_pressed():

func _on_LoadButton_pressed():

func _on_FileDialog_file_selected(path):
    if $HUD/FileDialog.get_mode() == FileDialog.MODE_OPEN_FILE:
        _poses = FileAccess.load(path)
    elif $HUD/FileDialog.get_mode() == FileDialog.MODE_SAVE_FILE:
        FileAccess.save(_poses, path)
in Engine by (61 points)

1 Answer

+1 vote
Best answer

FileDialog is really buggy. To mitigate the many issues the _draw function can be overridden. This script is attached to a FileDialog node. In this case setting and refreshing the directory does work and by deselecting the items at least one can choose the file without the dialog closing.

extends FileDialog

func _draw():
by (61 points)
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.