Browse Source

Allow absolute file paths in file dialogs

(cherry picked from commit a5e30c0228ace4f5ae87e034e9370ee4f0925e54)
miremrie 3 years ago
parent
commit
8a6b066ab7
2 changed files with 4 additions and 2 deletions
  1. 2 1
      editor/editor_file_dialog.cpp
  2. 2 1
      scene/gui/file_dialog.cpp

+ 2 - 1
editor/editor_file_dialog.cpp

@@ -378,7 +378,8 @@ void EditorFileDialog::_action_pressed() {
 		return;
 	}
 
-	String f = dir_access->get_current_dir().plus_file(file->get_text());
+	String file_text = file->get_text();
+	String f = file_text.is_abs_path() ? file_text : dir_access->get_current_dir().plus_file(file_text);
 
 	if ((mode == MODE_OPEN_ANY || mode == MODE_OPEN_FILE) && dir_access->file_exists(f)) {
 		_save_to_recent();

+ 2 - 1
scene/gui/file_dialog.cpp

@@ -195,7 +195,8 @@ void FileDialog::_action_pressed() {
 		return;
 	}
 
-	String f = dir_access->get_current_dir().plus_file(file->get_text());
+	String file_text = file->get_text();
+	String f = file_text.is_abs_path() ? file_text : dir_access->get_current_dir().plus_file(file_text);
 
 	if ((mode == MODE_OPEN_ANY || mode == MODE_OPEN_FILE) && dir_access->file_exists(f)) {
 		emit_signal("file_selected", f);