Inheritance #
- AudioServer
- CameraServer
- ClassDB
- DisplayServer
- EditorFileSystemDirectory
- EditorInterface
- EditorPaths
- EditorSelection
- EditorUndoRedoManager
- EditorVCSInterface
- Engine
- EngineDebugger
- FramebufferCacheRD
- GDExtensionManager
- Geometry2D
- Geometry3D
- IP
- Input
- InputMap
- JNISingleton
- JSONRPC
- JavaClassWrapper
- JavaScriptBridge
- MainLoop (1)
- Marshalls
- MovieWriter
- NativeMenu
- NavigationMeshGenerator
- NavigationServer2D
- NavigationServer3D
- Node (21)
- OS
- OpenXRExtensionWrapperExtension
- OpenXRInteractionProfileMetadata
- Performance
- PhysicsDirectBodyState2D (1)
- PhysicsDirectBodyState3D (1)
- PhysicsDirectSpaceState2D (1)
- PhysicsDirectSpaceState3D (1)
- PhysicsServer2D (1)
- PhysicsServer2DManager
- PhysicsServer3D (1)
- PhysicsServer3DManager
- PhysicsServer3DRendering
ServerHandler
- ProjectSettings
- RefCounted (121)
- RenderData (2)
- RenderSceneData (2)
- RenderingDevice
- RenderingServer
- ResourceLoader
- ResourceSaver
- ResourceUID
- ScriptLanguage (1)
- ShaderIncludeDB
- TextServerManager
- ThemeDB
- TileData
- Time
- TranslationServer
- TreeItem
- UndoRedo
- UniformSetCacheRD
- WorkerThreadPool
- XRServer
- XRVRS
- AnimationMixer (2)
- AudioStreamPlayer
- CanvasItem (2)
- CanvasLayer (1)
- EditorFileSystem
- EditorPlugin (1)
- EditorResourcePreview
- HTTPRequest
- InstancePlaceholder
- MissingNode
- MultiplayerSpawner
- MultiplayerSynchronizer
- NavigationAgent2D
- NavigationAgent3D
- Node3D (31)
- ResourcePreloader
- ShaderGlobalsOverride
- StatusIndicator
- Timer
- Viewport (2)
- WorldEnvironment
Table of contents
-
var access = ACCESS_RESOURCES -
var current_dir: String -
var current_file: String -
var current_path: String -
var dialog_hide_on_ok: bool = false -
var file_mode = FILE_MODE_SAVE_FILE -
var filename_filter: String = "" -
var filters: PackedStringArray = PackedStringArray() -
var mode_overrides_title: bool = true -
var ok_button_text: String = "Save" -
var option_count: int = 0 -
var root_subfolder: String = "" -
var show_hidden_files: bool = false -
var size: Vector2i = Vector2i(640, 360) -
var title: String = "Save a File" -
var use_native_dialog: bool = false -
func add_filter(description: String = "") -> void -
func add_option(default_value_index: int) -> void -
func clear_filename_filter() -> void -
func clear_filters() -> void -
func deselect_all() -> void -
func get_line_edit() -> LineEdit -
const func get_option_default(option: int) -> int -
const func get_option_name(option: int) -> String -
const func get_option_values(option: int) -> PackedStringArray -
const func get_selected_options() -> Dictionary -
func get_vbox() -> VBoxContainer -
func invalidate() -> void -
func set_option_default(default_value_index: int) -> void -
func set_option_name(name: String) -> void -
func set_option_values(values: PackedStringArray) -> void -
const FILE_MODE_OPEN_FILE = 0 enum FileMode -
const FILE_MODE_OPEN_FILES = 1 enum FileMode -
const FILE_MODE_OPEN_DIR = 2 enum FileMode -
const FILE_MODE_OPEN_ANY = 3 enum FileMode -
const FILE_MODE_SAVE_FILE = 4 enum FileMode -
const ACCESS_RESOURCES = 0 enum Access -
const ACCESS_USERDATA = 1 enum Access -
const ACCESS_FILESYSTEM = 2 enum Access -
enum FileMode -
enum Access -
signal dir_selected(dir: String) -
signal file_selected(path: String) -
signal filename_filter_changed(filter: String) -
signal files_selected(paths: PackedStringArray) -
self["theme_override_colors/file_disabled_color"] = Color(1, 1, 1, 0.25) as Color -
self["theme_override_colors/file_icon_color"] = Color(1, 1, 1, 1) as Color -
self["theme_override_colors/folder_icon_color"] = Color(1, 1, 1, 1) as Color -
self["theme_override_icons/back_folder"] = icon as Texture2D -
self["theme_override_icons/create_folder"] = icon as Texture2D -
self["theme_override_icons/file"] = icon as Texture2D -
self["theme_override_icons/folder"] = icon as Texture2D -
self["theme_override_icons/forward_folder"] = icon as Texture2D -
self["theme_override_icons/parent_folder"] = icon as Texture2D -
self["theme_override_icons/reload"] = icon as Texture2D -
self["theme_override_icons/toggle_filename_filter"] = icon as Texture2D -
self["theme_override_icons/toggle_hidden"] = icon as Texture2D
FileDialog #
is_instantiable, Node, core, not_builtin_classes
A dialog for selecting files or directories in the filesystem.
FileDialog is a preset dialog used to choose files and directories in the filesystem. It supports filter masks. FileDialog automatically sets its window title according to the file_mode. If you want to use a custom title, disable this by setting mode_overrides_title to false.
Members #
var access = ACCESS_RESOURCES#
The file system access scope. See Access constants.
Warning: In Web builds, FileDialog cannot access the host file system. In sandboxed Linux and macOS environments, use_native_dialog is automatically used to allow limited access to host file system.
var current_dir: String#
The current working directory of the file dialog.
Note: For native file dialogs, this property is only treated as a hint and may not be respected by specific OS implementations.
var current_file: String#
The currently selected file of the file dialog.
var current_path: String#
The currently selected file path of the file dialog.
var dialog_hide_on_ok: bool = false#
var file_mode = FILE_MODE_SAVE_FILE#
The dialog's open or save mode, which affects the selection behavior. See FileMode.
var filename_filter: String = ""#
The filter for file names (case-insensitive). When set to a non-empty string, only files that contains the substring will be shown. filename_filter can be edited by the user with the filter button at the top of the file dialog.
See also filters, which should be used to restrict the file types that can be selected instead of filename_filter which is meant to be set by the user.
var filters: PackedStringArray = PackedStringArray()#
The available file type filters. Each filter string in the array should be formatted like this: *.png,*.jpg,*.jpeg;Image Files;image/png,image/jpeg. The description text of the filter is optional and can be omitted. Both file extensions and MIME type should be always set.
Note: Embedded file dialog and Windows file dialog support only file extensions, while Android, Linux, and macOS file dialogs also support MIME types.
var mode_overrides_title: bool = true#
If true, changing the file_mode property will set the window title accordingly (e.g. setting file_mode to FILE_MODE_OPEN_FILE will change the window title to "Open a File").
var ok_button_text: String = "Save"#
var option_count: int = 0#
The number of additional OptionButtons and CheckBoxes in the dialog.
var root_subfolder: String = ""#
If non-empty, the given sub-folder will be "root" of this FileDialog, i.e. user won't be able to go to its parent directory.
Note: This property is ignored by native file dialogs.
var show_hidden_files: bool = false#
If true, the dialog will show hidden files.
Note: This property is ignored by native file dialogs on Android and Linux.
var size: Vector2i = Vector2i(640, 360)#
var title: String = "Save a File"#
var use_native_dialog: bool = false#
If true, and if supported by the current DisplayServer, OS native dialog will be used instead of custom one.
Note: On Android, it is only supported when using ACCESS_FILESYSTEM. For access mode ACCESS_RESOURCES and ACCESS_USERDATA, the system will fall back to custom FileDialog.
Note: On Linux and macOS, sandboxed apps always use native dialogs to access the host file system.
Note: On macOS, sandboxed apps will save security-scoped bookmarks to retain access to the opened folders across multiple sessions. Use OS.get_granted_permissions to get a list of saved bookmarks.
Note: Native dialogs are isolated from the base process, file dialog properties can't be modified once the dialog is shown.
Methods #
func add_filter(description: String = "") -> void#
Adds a comma-delimited file name filter option to the FileDialog 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 "*.png, *.jpg" and a description of "Images" results in filter text "Images (*.png, *.jpg)".
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 clear_filename_filter() -> void#
Clear the filter for file names.
func clear_filters() -> void#
Clear all the added filters in the dialog.
func deselect_all() -> void#
Clear all currently selected items in the dialog.
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 vertical box container of the dialog, custom controls can be added to it.
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.
Note: Changes to this node are ignored by native file dialogs, use add_option to add custom elements to the dialog instead.
func invalidate() -> void#
Invalidate and update the current dialog content list.
Note: This method does nothing on native file dialogs.
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 dialog allows selecting one, and only one file.
const FILE_MODE_OPEN_FILES = 1 enum FileMode#
The dialog allows selecting multiple files.
const FILE_MODE_OPEN_DIR = 2 enum FileMode#
The dialog only allows selecting a directory, disallowing the selection of any file.
const FILE_MODE_OPEN_ANY = 3 enum FileMode#
The dialog allows selecting one file or directory.
const FILE_MODE_SAVE_FILE = 4 enum FileMode#
The dialog will warn when a file exists.
const ACCESS_RESOURCES = 0 enum Access#
The dialog only allows accessing files under the Resource path (res://).
const ACCESS_USERDATA = 1 enum Access#
The dialog only allows accessing files under user data path (user://).
const ACCESS_FILESYSTEM = 2 enum Access#
The dialog allows accessing files on the whole file system.
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,
} Operators #
Signals #
signal dir_selected(dir: String)#
Emitted when the user selects a directory.
signal file_selected(path: String)#
Emitted when the user selects a file by double-clicking it or pressing the OK button.
signal filename_filter_changed(filter: String)#
Emitted when the filter for file names changes.
signal files_selected(paths: PackedStringArray)#
Emitted when the user selects multiple files.
Theme Items #
self["theme_override_colors/file_disabled_color"] = Color(1, 1, 1, 0.25) as Color#
The color tint for disabled files (when the FileDialog is used in open folder mode).
self["theme_override_colors/file_icon_color"] = Color(1, 1, 1, 1) as Color#
The color modulation applied to the file icon.
self["theme_override_colors/folder_icon_color"] = Color(1, 1, 1, 1) as Color#
The color modulation applied to the folder icon.
self["theme_override_icons/back_folder"] = icon as Texture2D#
Custom icon for the back arrow.
self["theme_override_icons/create_folder"] = icon as Texture2D#
Custom icon for the create folder button.
self["theme_override_icons/file"] = icon as Texture2D#
Custom icon for files.
self["theme_override_icons/folder"] = icon as Texture2D#
Custom icon for folders.
self["theme_override_icons/forward_folder"] = icon as Texture2D#
Custom icon for the forward arrow.
self["theme_override_icons/parent_folder"] = icon as Texture2D#
Custom icon for the parent folder arrow.
self["theme_override_icons/reload"] = icon as Texture2D#
Custom icon for the reload button.
self["theme_override_icons/toggle_filename_filter"] = icon as Texture2D#
Custom icon for the toggle button for the filter for file names.
self["theme_override_icons/toggle_hidden"] = icon as Texture2D#
Custom icon for the toggle hidden button.