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)
asked Apr 22, 2019 in Engine by bborncr (57 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():
answered Apr 23, 2019 by bborncr (57 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 How to use this Q&A? before posting your first questions.