Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | bborncr |
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():
$HUD/FileDialog.set_mode(FileDialog.MODE_SAVE_FILE)
$HUD/FileDialog.show()
func _on_LoadButton_pressed():
$HUD/FileDialog.set_mode(FileDialog.MODE_OPEN_FILE)
$HUD/FileDialog.show()
func _on_FileDialog_file_selected(path):
if $HUD/FileDialog.get_mode() == FileDialog.MODE_OPEN_FILE:
print("Loading...")
print(path)
_poses = FileAccess.load(path)
elif $HUD/FileDialog.get_mode() == FileDialog.MODE_SAVE_FILE:
print("Saving...")
print(path)
FileAccess.save(_poses, path)