Class reference
EditorFileDialog
Inherits ConfirmationDialog
A modified version of FileDialog used by the editor.
Description
EditorFileDialog is an enhanced version of FileDialog available only to editor plugins. Additional features include list of favorited/recent files and the ability to see files as thumbnails grid instead of list. Unlike FileDialog, EditorFileDialog does not have a property for using native dialogs. Instead, native dialogs can be enabled globally via the EditorSettings.interface/editor/use_native_file_dialogs editor setting. They are also enabled automatically when running in sandbox (e.g. on macOS).
Properties
int access = 0
int access = 0The location from which the user may select a file, including res://, user://, and the local file system.
String current_dir
String current_dirThe currently occupied directory.
String current_file
String current_fileThe currently selected file.
String current_path
String current_pathThe file system path in the address bar.
bool dialog_hide_on_ok = false
bool dialog_hide_on_ok = falsebool disable_overwrite_warning = false
bool disable_overwrite_warning = falseIf true, the EditorFileDialog will not warn the user before overwriting files.
int display_mode = 0
int display_mode = 0The view format in which the EditorFileDialog displays resources to the user.
int file_mode = 4
int file_mode = 4The dialog's open or save mode, which affects the selection behavior.
PackedStringArray filters = PackedStringArray()
PackedStringArray filters = PackedStringArray()The available file type filters. For example, this shows only .png and .gd files: set_filters(PackedStringArray(["*.png ; PNG Images","*.gd ; GDScript Files"])). Multiple file types can also be specified in a single filter. "*.png, *.jpg, *.jpeg ; Supported Images" will show both PNG and JPEG files when selected.
int option_count = 0
int option_count = 0The number of additional OptionButtons and CheckBoxes in the dialog.
bool show_hidden_files = false
bool show_hidden_files = falseIf true, hidden files and directories will be visible in the EditorFileDialog. This property is synchronized with EditorSettings.filesystem/file_dialog/show_hidden_files.
String title = "Save a File"
String title = "Save a File"Methods
void add_filter(String filter, String description = "")
String filter, String description = "")Adds a comma-separated file name filter option to the EditorFileDialog with an optional description, which restricts what files can be picked. A filter should be of the form "filename.extension", where filename and extension can be * to match any string. Filters starting with . (i.e. empty filenames) are not allowed. For example, a filter of "*.tscn, *.scn" and a description of "Scenes" results in filter text "Scenes (*.tscn, *.scn)".
void add_option(String name, PackedStringArray values, int default_value_index)
String name, PackedStringArray values, int default_value_index)Adds an additional OptionButton to the file dialog. If values is empty, a CheckBox is added instead. default_value_index should be an index of the value in the values. If values is empty it should be either 1 (checked), or 0 (unchecked).
void add_side_menu(Control menu, String title = "")
Control menu, String title = "")Adds the given menu to the side of the file dialog with the given title text on top. Only one side menu is allowed.
void clear_filename_filter()
Clear the filter for file names.
void clear_filters()
Removes all filters except for "All Files (*.*)".
String get_filename_filter() const
String get_filename_filter() constReturns the value of the filter for file names.
LineEdit get_line_edit()
LineEdit get_line_edit()Returns the LineEdit for the selected file. Warning: This is a required internal node, removing and freeing it may cause a crash. If you wish to hide it or any of its children, use their CanvasItem.visible property.
int get_option_default(int option) const
int get_option_default(int option) constReturns the default value index of the OptionButton or CheckBox with index option.
String get_option_name(int option) const
String get_option_name(int option) constReturns the name of the OptionButton or CheckBox with index option.
PackedStringArray get_option_values(int option) const
PackedStringArray get_option_values(int option) constReturns an array of values of the OptionButton with index option.
Dictionary get_selected_options() const
Dictionary get_selected_options() constReturns a Dictionary with the selected values of the additional OptionButtons and/or CheckBoxes. Dictionary keys are names and values are selected value indices.
VBoxContainer get_vbox()
VBoxContainer get_vbox()Returns the VBoxContainer used to display the file system. Warning: This is a required internal node, removing and freeing it may cause a crash. If you wish to hide it or any of its children, use their CanvasItem.visible property.
void invalidate()
Notify the EditorFileDialog that its view of the data is no longer accurate. Updates the view contents on next view update.
void popup_file_dialog()
Shows the EditorFileDialog at the default size and position for file dialogs in the editor, and selects the file name if there is a current file.
void set_filename_filter(String filter)
String filter)Sets the value of the filter for file names.
void set_option_default(int option, int default_value_index)
int option, int default_value_index)Sets the default value index of the OptionButton or CheckBox with index option.
void set_option_name(int option, String name)
int option, String name)Sets the name of the OptionButton or CheckBox with index option.
void set_option_values(int option, PackedStringArray values)
int option, PackedStringArray values)Sets the option values of the OptionButton with index option.
Signals
dir_selected(String dir)
String dir)Emitted when a directory is selected.
file_selected(String path)
String path)Emitted when a file is selected.
filename_filter_changed(String filter)
String filter)Emitted when the filter for file names changes.
files_selected(PackedStringArray paths)
PackedStringArray paths)Emitted when multiple files are selected.
Constants
FILE_MODE_OPEN_FILE = 0
The EditorFileDialog can select only one file. Accepting the window will open the file.
FILE_MODE_OPEN_FILES = 1
The EditorFileDialog can select multiple files. Accepting the window will open all files.
FILE_MODE_OPEN_DIR = 2
The EditorFileDialog can select only one directory. Accepting the window will open the directory.
FILE_MODE_OPEN_ANY = 3
The EditorFileDialog can select a file or directory. Accepting the window will open it.
FILE_MODE_SAVE_FILE = 4
The EditorFileDialog can select only one file. Accepting the window will save the file.
ACCESS_RESOURCES = 0
The EditorFileDialog can only view res:// directory contents.
ACCESS_USERDATA = 1
The EditorFileDialog can only view user:// directory contents.
ACCESS_FILESYSTEM = 2
The EditorFileDialog can view the entire local file system.
DISPLAY_THUMBNAILS = 0
The EditorFileDialog displays resources as thumbnails.
DISPLAY_LIST = 1
The EditorFileDialog displays resources as a list of filenames.