EditorFileDialog
繼承: ConfirmationDialog < AcceptDialog < Window < Viewport < Node < Object
編輯器使用的 FileDialog 的修改版。
說明
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).
屬性
|
||
dialog_hide_on_ok |
|
|
|
||
|
||
|
||
|
||
|
||
|
||
title |
|
方法
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 |
|
void |
|
get_filename_filter() const |
|
get_option_default(option: int) const |
|
get_option_name(option: int) const |
|
get_option_values(option: int) const |
|
get_selected_options() const |
|
get_vbox() |
|
void |
|
void |
|
void |
set_filename_filter(filter: String) |
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) |
訊號
選擇目錄時觸發。
選擇檔時觸發。
filename_filter_changed(filter: String) 🔗
Emitted when the filter for file names changes.
files_selected(paths: PackedStringArray) 🔗
選擇多個檔時觸發。
列舉
enum FileMode: 🔗
FileMode FILE_MODE_OPEN_FILE = 0
EditorFileDialog 僅可以選擇一個檔,選擇同意視窗將會打開這個檔。
FileMode FILE_MODE_OPEN_FILES = 1
EditorFileDialog 可以選擇多個檔,選擇同意視窗將會打開所有選擇的檔。
FileMode FILE_MODE_OPEN_DIR = 2
EditorFileDialog 可以選擇一個目錄,選擇同意視窗將會打開這個目錄。
FileMode FILE_MODE_OPEN_ANY = 3
EditorFileDialog 可以選擇一個檔或者目錄,選擇同意視窗將會打開這個檔或目錄。
FileMode FILE_MODE_SAVE_FILE = 4
EditorFileDialog 可以選擇一個檔,選擇同意視窗將會保存這個檔。
enum Access: 🔗
Access ACCESS_RESOURCES = 0
EditorFileDialog 只能查看 res:// 目錄裡的內容。
Access ACCESS_USERDATA = 1
EditorFileDialog 只能查看user:// 目錄裡的內容。
Access ACCESS_FILESYSTEM = 2
EditorFileDialog 可以查看整個本地檔案系統。
enum DisplayMode: 🔗
DisplayMode DISPLAY_THUMBNAILS = 0
EditorFileDialog 以圖示的形式顯示資源。
DisplayMode DISPLAY_LIST = 1
EditorFileDialog 以檔案名列表的形式顯示資源。
屬性說明
使用者可以選擇檔的位置,包括 res://、user:// 和本地檔案系統。
目前佔用的目錄。
目前選擇的檔案。
位址欄中的檔案系統路徑。
bool disable_overwrite_warning = false 🔗
如果為 true,EditorFileDialog 將不會在覆蓋檔之前警告使用者。
DisplayMode display_mode = 0 🔗
void set_display_mode(value: DisplayMode)
DisplayMode get_display_mode()
EditorFileDialog 向使用者顯示資源的視圖格式。
The dialog's open or save mode, which affects the selection behavior.
PackedStringArray filters = PackedStringArray() 🔗
void set_filters(value: PackedStringArray)
PackedStringArray get_filters()
可用的檔案型別篩檢程式。例如,這樣就只會顯示 .png 和 .gd 檔案:set_filters(PackedStringArray(["*.png ; PNG Images","*.gd ; GDScript Files"]))。也可以在單個篩檢程式中指定多種檔案型別。選中 "*.png, *.jpg, *.jpeg ; 支援的圖片" 時,將同時顯示 PNG 和 JPEG 檔案。
Note: The returned array is copied and any changes to it will not update the original property value. See PackedStringArray for more details.
The number of additional OptionButtons and CheckBoxes in the dialog.
如果為 true,隱藏的檔和目錄將在 EditorFileDialog 中可見。該屬性與 EditorSettings.filesystem/file_dialog/show_hidden_files 同步。
方法說明
void add_filter(filter: String, description: String = "") 🔗
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(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).
將給定的 menu 新增到檔案對話方塊的一側,給定的title 文字位於頂部。只允許一個側面選單。
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 🔗
Returns the value of the filter for file names.
返回所選檔案的 LineEdit。
警告:這是一個必需的內部節點,刪除和釋放它可能會導致當機。如果你希望隱藏它或其任何子項,請使用它們的 CanvasItem.visible 屬性。
int get_option_default(option: int) const 🔗
Returns the default value index of the OptionButton or CheckBox with index option.
String get_option_name(option: int) const 🔗
Returns the name of the OptionButton or CheckBox with index option.
PackedStringArray get_option_values(option: int) const 🔗
Returns an array of values of the OptionButton with index option.
Dictionary get_selected_options() const 🔗
Returns 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() 🔗
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() 🔗
通知 EditorFileDialog 它的資料視圖不再準確。在下次視圖更新時更新視圖內容。
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(filter: String) 🔗
Sets the value of the filter for file names.
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.