EditorFileDialog
继承: ConfirmationDialog
< AcceptDialog
< Window
< Viewport
< Node
< Object
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.
属性
方法
void | add_filter ( filter: String , description: String = "" ) |
void | add_option ( name: String , values: PackedStringArray , default_value_index: int ) |
void | add_side_menu ( menu: Control , title: String = "" ) |
void | clear_filters ( ) |
LineEdit | get_line_edit ( ) |
int | get_option_default ( option: int ) const1 |
String | get_option_name ( option: int ) const1 |
PackedStringArray | get_option_values ( option: int ) const1 |
Dictionary | get_selected_options ( ) const1 |
VBoxContainer | get_vbox ( ) |
void | invalidate ( ) |
void | popup_file_dialog ( ) |
void | set_option_default ( option: int , default_value_index: int ) |
void | set_option_name ( option: int , name: String ) |
void | set_option_values ( option: int , values: PackedStringArray ) |
信号
dir_selected ( dir: String
)
Emitted when a directory is selected.
file_selected ( path: String
)
Emitted when a file is selected.
files_selected ( paths: PackedStringArray
)
Emitted when multiple files are selected.
枚举
enum FileMode:
FileMode FILE_MODE_OPEN_FILE = 0
The EditorFileDialog can select only one file. Accepting the window will open the file.
FileMode FILE_MODE_OPEN_FILES = 1
The EditorFileDialog can select multiple files. Accepting the window will open all files.
FileMode FILE_MODE_OPEN_DIR = 2
The EditorFileDialog can select only one directory. Accepting the window will open the directory.
FileMode FILE_MODE_OPEN_ANY = 3
The EditorFileDialog can select a file or directory. Accepting the window will open it.
FileMode FILE_MODE_SAVE_FILE = 4
The EditorFileDialog can select only one file. Accepting the window will save the file.
enum Access:
Access ACCESS_RESOURCES = 0
The EditorFileDialog can only view res://
directory contents.
Access ACCESS_USERDATA = 1
The EditorFileDialog can only view user://
directory contents.
Access ACCESS_FILESYSTEM = 2
The EditorFileDialog can view the entire local file system.
enum DisplayMode:
DisplayMode DISPLAY_THUMBNAILS = 0
The EditorFileDialog displays resources as thumbnails.
DisplayMode DISPLAY_LIST = 1
The EditorFileDialog displays resources as a list of filenames.
属性说明
Access access = 0
The location from which the user may select a file, including res://
, user://
, and the local file system.
String
current_dir
The currently occupied directory.
String
current_file
The currently selected file.
String
current_path
The file system path in the address bar.
bool
disable_overwrite_warning = false
If true
, the EditorFileDialog will not warn the user before overwriting files.
DisplayMode display_mode = 0
void
set_display_mode ( value: DisplayMode )- DisplayMode get_display_mode ( )
The view format in which the EditorFileDialog displays resources to the user.
FileMode file_mode = 4
The dialog's open or save mode, which affects the selection behavior. See FileMode.
PackedStringArray
filters = PackedStringArray()
void
set_filters ( value:PackedStringArray
)PackedStringArray
get_filters ( )
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.
Note: The returned array is copied and any changes to it will not update the original property value. See PackedStringArray
for more details.
int
option_count = 0
The number of additional OptionButton
s and CheckBox
es in the dialog.
bool
show_hidden_files = 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
.
方法说明
void
add_filter ( filter: String
, description: String
= "" )
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)".
void
add_option ( name: String
, values: PackedStringArray
, default_value_index: int
)
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 ( menu: Control
, title: String
= "" )
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_filters ( )
Removes all filters except for "All Files (*)".
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 ( option: int
) const1
Returns the default value index of the OptionButton
or CheckBox
with index option
.
String
get_option_name ( option: int
) const1
Returns the name of the OptionButton
or CheckBox
with index option
.
PackedStringArray
get_option_values ( option: int
) const1
Returns an array of values of the OptionButton
with index option
.
Dictionary
get_selected_options ( ) const1
Returns a Dictionary
with the selected values of the additional OptionButton
s and/or CheckBox
es. Dictionary
keys are names and values are selected value indices.
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_option_default ( option: int
, default_value_index: int
)
Sets the default value index of the OptionButton
or CheckBox
with index option
.
void
set_option_name ( option: int
, name: String
)
Sets the name of the OptionButton
or CheckBox
with index option
.
void
set_option_values ( option: int
, values: PackedStringArray
)
Sets the option values of the OptionButton
with index option
.
本方法通常需要用户覆盖才能生效。
本方法无副作用,不会修改该实例的任何成员变量。
本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。
本方法用于构造某个类型。
调用本方法无需实例,可直接使用类名进行调用。
本方法描述的是使用本类型作为左操作数的有效运算符。
这个值是由下列位标志构成位掩码的整数。
无返回值。