Dialog for selecting files or directories in the filesystem.
    public class FileDialog : ConfirmationDialog

FileDialog is a preset dialog used to choose files and directories in the filesystem. It supports filter masks.

Inheritance Chain

Constructors

    public FileDialog()

Signals

    "dir_selected" (String dir)

Emitted when the user selects a directory.

    "file_selected" (String path)

Emitted when the user selects a file by double-clicking it or pressing the OK button.

    "files_selected" (PoolStringArray paths)

Emitted when the user selects multiple files.

Properties

    public AccessEnum Access { get; set; }

The file system access scope. See enum Access constants.

    public string CurrentDir { get; set; }

The current working directory of the file dialog.

    public string CurrentFile { get; set; }

The currently selected file of the file dialog.

    public string CurrentPath { get; set; }

The currently selected file path of the file dialog.

    public string[] Filters { get; set; }

The available file type filters. For example, this shows only .png and .gd files: set_filters(PoolStringArray(["*.png ; PNG Images","*.gd ; GDScript Files"])).

    public ModeEnum Mode { get; set; }

The dialog’s open or save mode, which affects the selection behavior. See enum Mode constants.

    public bool ModeOverridesTitle { get; set; }

If true, changing the Mode property will set the window title accordingly (e.g. setting mode to [constant MODE_OPEN_FILE] will change the window title to “Open a File”).

    public bool ShowHiddenFiles { get; set; }

If true, the dialog will show hidden files.

Methods

    public void AddFilter(string filter)

Adds filter as a custom filter; filter should be of the form "filename.extension ; Description". For example, "*.png ; PNG Images".

    public void ClearFilters()

Clear all the added filters in the dialog.

    public void DeselectItems()

Clear currently selected items in the dialog.

    [Obsolete("GetAccess is deprecated. Use the Access property instead.")]
    public AccessEnum GetAccess()

Getter for Access

    [Obsolete("GetCurrentDir is deprecated. Use the CurrentDir property instead.")]
    public string GetCurrentDir()

Getter for CurrentDir

    [Obsolete("GetCurrentFile is deprecated. Use the CurrentFile property instead.")]
    public string GetCurrentFile()

Getter for CurrentFile

    [Obsolete("GetCurrentPath is deprecated. Use the CurrentPath property instead.")]
    public string GetCurrentPath()

Getter for CurrentPath

    [Obsolete("GetFilters is deprecated. Use the Filters property instead.")]
    public string[] GetFilters()

Getter for Filters

    public LineEdit GetLineEdit()

Returns the LineEdit for the selected file.

    [Obsolete("GetMode is deprecated. Use the Mode property instead.")]
    public ModeEnum GetMode()

Getter for Mode

    public VBoxContainer GetVbox()

Returns the vertical box container of the dialog, custom controls can be added to it.

    public void Invalidate()

Invalidate and update the current dialog content list.

    [Obsolete("IsModeOverridingTitle is deprecated. Use the ModeOverridesTitle property instead.")]
    public bool IsModeOverridingTitle()

Getter for ModeOverridesTitle

    [Obsolete("IsShowingHiddenFiles is deprecated. Use the ShowHiddenFiles property instead.")]
    public bool IsShowingHiddenFiles()

Getter for ShowHiddenFiles

    [Obsolete("SetAccess is deprecated. Use the Access property instead.")]
    public void SetAccess(AccessEnum access)

Setter for Access

    [Obsolete("SetCurrentDir is deprecated. Use the CurrentDir property instead.")]
    public void SetCurrentDir(string dir)

Setter for CurrentDir

    [Obsolete("SetCurrentFile is deprecated. Use the CurrentFile property instead.")]
    public void SetCurrentFile(string file)

Setter for CurrentFile

    [Obsolete("SetCurrentPath is deprecated. Use the CurrentPath property instead.")]
    public void SetCurrentPath(string path)

Setter for CurrentPath

    [Obsolete("SetFilters is deprecated. Use the Filters property instead.")]
    public void SetFilters(string[] filters)

Setter for Filters

    [Obsolete("SetMode is deprecated. Use the Mode property instead.")]
    public void SetMode(ModeEnum mode)

Setter for Mode

    [Obsolete("SetModeOverridesTitle is deprecated. Use the ModeOverridesTitle property instead.")]
    public void SetModeOverridesTitle(bool @override)

Setter for ModeOverridesTitle

    [Obsolete("SetShowHiddenFiles is deprecated. Use the ShowHiddenFiles property instead.")]
    public void SetShowHiddenFiles(bool show)

Setter for ShowHiddenFiles

Inner Types

AccessEnum

Name Value Description
Resources 0 The dialog only allows accessing files under the [Resource] path ([code]res://[/code]).
Userdata 1 The dialog only allows accessing files under user data path ([code]user://[/code]).
Filesystem 2 The dialog allows accessing files on the whole file system.

ModeEnum

Name Value Description
OpenFile 0 The dialog allows selecting one, and only one file.
OpenFiles 1 The dialog allows selecting multiple files.
OpenDir 2 The dialog only allows selecting a directory, disallowing the selection of any file.
OpenAny 3 The dialog allows selecting one file or directory.
SaveFile 4 The dialog will warn when a file exists.
Tags: