From adceb32177b0b1e5f1328544c583c58c90c1da48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pa=CC=84vels=20Nadtoc=CC=8Cajevs?= <7645683+bruvzg@users.noreply.github.com> Date: Mon, 27 Jan 2025 10:08:32 +0200 Subject: [PATCH] Fix FILE_MODE_OPEN_ANY file dialog not selecting folders. --- doc/classes/FileDialog.xml | 1 + scene/gui/file_dialog.cpp | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/doc/classes/FileDialog.xml b/doc/classes/FileDialog.xml index 921fb0b7146..aced51b906c 100644 --- a/doc/classes/FileDialog.xml +++ b/doc/classes/FileDialog.xml @@ -151,6 +151,7 @@ If [code]true[/code], changing the [member file_mode] property will set the window title accordingly (e.g. setting [member file_mode] to [constant FILE_MODE_OPEN_FILE] will change the window title to "Open a File"). + The number of additional [OptionButton]s and [CheckBox]es in the dialog. diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index d685da9a52c..b9450fd77f0 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -637,8 +637,10 @@ void FileDialog::deselect_all() { set_ok_button_text(ETR("Select Current Folder")); break; case FILE_MODE_OPEN_ANY: + set_ok_button_text(ETR("Open")); + break; case FILE_MODE_SAVE_FILE: - // FIXME: Implement, or refactor to avoid duplication with set_mode + set_ok_button_text(ETR("Save")); break; } } @@ -657,7 +659,13 @@ void FileDialog::_tree_selected() { if (!d["dir"]) { file->set_text(d["name"]); - } else if (mode == FILE_MODE_OPEN_DIR) { + if (mode == FILE_MODE_SAVE_FILE) { + set_ok_button_text(ETR("Save")); + } else { + set_ok_button_text(ETR("Open")); + } + } else if (mode == FILE_MODE_OPEN_DIR || mode == FILE_MODE_OPEN_ANY) { + file->set_text(""); set_ok_button_text(ETR("Select This Folder")); }