Inheritance #

EditorFileDialog
Table of contents

EditorFileDialog #

is_instantiable, Node, editor, not_builtin_classes

A modified version of FileDialog used by the editor.

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).

Members #

var access = ACCESS_RESOURCES#

The location from which the user may select a file, including res://, user://, and the local file system.

var current_dir: String#

The currently occupied directory.

var current_file: String#

The currently selected file.

var current_path: String#

The file system path in the address bar.

var dialog_hide_on_ok: bool = false#

var disable_overwrite_warning: bool = false#

If true, the EditorFileDialog will not warn the user before overwriting files.

var display_mode = DISPLAY_THUMBNAILS#

The view format in which the EditorFileDialog displays resources to the user.

var file_mode = FILE_MODE_SAVE_FILE#

The dialog's open or save mode, which affects the selection behavior. See FileMode.

var filters: PackedStringArray = 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.

var option_count: int = 0#

The number of additional OptionButtons and CheckBoxes in the dialog.

var show_hidden_files: bool = false#

If true, hidden files and directories will be visible in the EditorFileDialog. This property is synchronized with EditorSettings.filesystem/file_dialog/show_hidden_files.

var title: String = "Save a File"#

Methods #

func add_filter(description: String = "") -> void#

Adds a comma-delimited 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)".

func add_option(default_value_index: int) -> void#

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).

func add_side_menu(title: String = "") -> void#

Adds the given menu to the side of the file dialog with the given title text on top. Only one side menu is allowed.

func clear_filename_filter() -> void#

Clear the filter for file names.

func clear_filters() -> void#

Removes all filters except for "All Files (*.*)".

const func get_filename_filter() -> String#

Returns the value of the filter for file names.

func get_line_edit() -> LineEdit#

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.

const func get_option_default(option: int) -> int#

Returns the default value index of the OptionButton or CheckBox with index option.

const func get_option_name(option: int) -> String#

Returns the name of the OptionButton or CheckBox with index option.

const func get_option_values(option: int) -> PackedStringArray#

Returns an array of values of the OptionButton with index option.

const func get_selected_options() -> Dictionary#

Returns a Dictionary with the selected values of the additional OptionButtons and/or CheckBoxes. Dictionary keys are names and values are selected value indices.

func get_vbox() -> VBoxContainer#

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.

func invalidate() -> void#

Notify the EditorFileDialog that its view of the data is no longer accurate. Updates the view contents on next view update.

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.

func set_filename_filter(filter: String) -> void#

Sets the value of the filter for file names.

func set_option_default(default_value_index: int) -> void#

Sets the default value index of the OptionButton or CheckBox with index option.

func set_option_name(name: String) -> void#

Sets the name of the OptionButton or CheckBox with index option.

func set_option_values(values: PackedStringArray) -> void#

Sets the option values of the OptionButton with index option.

Annotations #

Constants #

const FILE_MODE_OPEN_FILE = 0 enum FileMode#

The EditorFileDialog can select only one file. Accepting the window will open the file.

const FILE_MODE_OPEN_FILES = 1 enum FileMode#

The EditorFileDialog can select multiple files. Accepting the window will open all files.

const FILE_MODE_OPEN_DIR = 2 enum FileMode#

The EditorFileDialog can select only one directory. Accepting the window will open the directory.

const FILE_MODE_OPEN_ANY = 3 enum FileMode#

The EditorFileDialog can select a file or directory. Accepting the window will open it.

const FILE_MODE_SAVE_FILE = 4 enum FileMode#

The EditorFileDialog can select only one file. Accepting the window will save the file.

const ACCESS_RESOURCES = 0 enum Access#

The EditorFileDialog can only view res:// directory contents.

const ACCESS_USERDATA = 1 enum Access#

The EditorFileDialog can only view user:// directory contents.

const ACCESS_FILESYSTEM = 2 enum Access#

The EditorFileDialog can view the entire local file system.

const DISPLAY_THUMBNAILS = 0 enum DisplayMode#

The EditorFileDialog displays resources as thumbnails.

const DISPLAY_LIST = 1 enum DisplayMode#

The EditorFileDialog displays resources as a list of filenames.

Constructors #

Enums #

FileMode#

enum FileMode { FILE_MODE_OPEN_FILE = 0, FILE_MODE_OPEN_FILES = 1, FILE_MODE_OPEN_DIR = 2, FILE_MODE_OPEN_ANY = 3, FILE_MODE_SAVE_FILE = 4, }

Access#

enum Access { ACCESS_RESOURCES = 0, ACCESS_USERDATA = 1, ACCESS_FILESYSTEM = 2, }

DisplayMode#

enum DisplayMode { DISPLAY_THUMBNAILS = 0, DISPLAY_LIST = 1, }

Operators #

Signals #

signal dir_selected(dir: String)#

Emitted when a directory is selected.

signal file_selected(path: String)#

Emitted when a file is selected.

signal filename_filter_changed(filter: String)#

Emitted when the filter for file names changes.

signal files_selected(paths: PackedStringArray)#

Emitted when multiple files are selected.

Theme Items #

Tutorials #