Debian Codegraph @

doc/classes/FileDialog.xml

raw symbols SCIP
1 <?xml version="1.0" encoding="UTF-8" ?>
2 <class name="FileDialog" inherits="ConfirmationDialog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
3 <brief_description>
4 A dialog for selecting files or directories in the filesystem.
5 </brief_description>
6 <description>
7 [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 [member file_mode]. If you want to use a custom title, disable this by setting [member mode_overrides_title] to [code]false[/code].
8 [b]Note:[/b] [FileDialog] is invisible by default. To make it visible, call one of the [code]popup_*[/code] methods from [Window] on the node, such as [method Window.popup_centered_clamped].
9 </description>
10 <tutorials>
11 </tutorials>
12 <methods>
13 <method name="add_filter">
14 <return type="void" />
15 <param index="0" name="filter" type="String" />
16 <param index="1" name="description" type="String" default="&quot;&quot;" />
17 <param index="2" name="mime_type" type="String" default="&quot;&quot;" />
18 <description>
19 Adds a comma-separated file extension [param filter] and comma-separated MIME type [param mime_type] option to the [FileDialog] with an optional [param description], which restricts what files can be picked.
20 A [param filter] should be of the form [code]"filename.extension"[/code], where filename and extension can be [code]*[/code] to match any string. Filters starting with [code].[/code] (i.e. empty filenames) are not allowed.
21 For example, a [param filter] of [code]"*.png, *.jpg"[/code], a [param mime_type] of [code]image/png, image/jpeg[/code], and a [param description] of [code]"Images"[/code] results in filter text "Images (*.png, *.jpg)".
22 [b]Note:[/b] Embedded file dialogs and Windows file dialogs support only file extensions, while Android, Linux, and macOS file dialogs also support MIME types.
23 </description>
24 </method>
25 <method name="add_option">
26 <return type="void" />
27 <param index="0" name="name" type="String" />
28 <param index="1" name="values" type="PackedStringArray" />
29 <param index="2" name="default_value_index" type="int" />
30 <description>
31 Adds an additional [OptionButton] to the file dialog. If [param values] is empty, a [CheckBox] is added instead.
32 [param default_value_index] should be an index of the value in the [param values]. If [param values] is empty it should be either [code]1[/code] (checked), or [code]0[/code] (unchecked).
33 </description>
34 </method>
35 <method name="clear_filename_filter">
36 <return type="void" />
37 <description>
38 Clear the filter for file names.
39 </description>
40 </method>
41 <method name="clear_filters">
42 <return type="void" />
43 <description>
44 Clear all the added filters in the dialog.
45 </description>
46 </method>
47 <method name="deselect_all">
48 <return type="void" />
49 <description>
50 Clear all currently selected items in the dialog.
51 </description>
52 </method>
53 <method name="get_favorite_list" qualifiers="static">
54 <return type="PackedStringArray" />
55 <description>
56 Returns the list of favorite directories, which is shared by all [FileDialog] nodes. Useful to store the list of favorites between project sessions. This method can be called only from the main thread.
57 </description>
58 </method>
59 <method name="get_line_edit">
60 <return type="LineEdit" />
61 <description>
62 Returns the LineEdit for the selected file.
63 [b]Warning:[/b] 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 [member CanvasItem.visible] property.
64 </description>
65 </method>
66 <method name="get_option_default" qualifiers="const">
67 <return type="int" />
68 <param index="0" name="option" type="int" />
69 <description>
70 Returns the default value index of the [OptionButton] or [CheckBox] with index [param option].
71 </description>
72 </method>
73 <method name="get_option_name" qualifiers="const">
74 <return type="String" />
75 <param index="0" name="option" type="int" />
76 <description>
77 Returns the name of the [OptionButton] or [CheckBox] with index [param option].
78 </description>
79 </method>
80 <method name="get_option_values" qualifiers="const">
81 <return type="PackedStringArray" />
82 <param index="0" name="option" type="int" />
83 <description>
84 Returns an array of values of the [OptionButton] with index [param option].
85 </description>
86 </method>
87 <method name="get_recent_list" qualifiers="static">
88 <return type="PackedStringArray" />
89 <description>
90 Returns the list of recent directories, which is shared by all [FileDialog] nodes. Useful to store the list of recents between project sessions. This method can be called only from the main thread.
91 </description>
92 </method>
93 <method name="get_selected_options" qualifiers="const">
94 <return type="Dictionary" />
95 <description>
96 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.
97 </description>
98 </method>
99 <method name="get_vbox">
100 <return type="VBoxContainer" />
101 <description>
102 Returns the vertical box container of the dialog, custom controls can be added to it.
103 [b]Warning:[/b] 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 [member CanvasItem.visible] property.
104 [b]Note:[/b] Changes to this node are ignored by native file dialogs, use [method add_option] to add custom elements to the dialog instead.
105 </description>
106 </method>
107 <method name="invalidate">
108 <return type="void" />
109 <description>
110 Invalidates and updates this dialog's content list.
111 [b]Note:[/b] This method does nothing on native file dialogs.
112 </description>
113 </method>
114 <method name="is_customization_flag_enabled" qualifiers="const">
115 <return type="bool" />
116 <param index="0" name="flag" type="int" enum="FileDialog.Customization" />
117 <description>
118 Returns [code]true[/code] if the provided [param flag] is enabled.
119 </description>
120 </method>
121 <method name="popup_file_dialog">
122 <return type="void" />
123 <description>
124 Shows the [FileDialog] using the default size and position for file dialogs, and selects the file name if there is a current file.
125 </description>
126 </method>
127 <method name="set_customization_flag_enabled">
128 <return type="void" />
129 <param index="0" name="flag" type="int" enum="FileDialog.Customization" />
130 <param index="1" name="enabled" type="bool" />
131 <description>
132 Sets the specified customization [param flag], allowing to customize the features available in this [FileDialog].
133 </description>
134 </method>
135 <method name="set_favorite_list" qualifiers="static">
136 <return type="void" />
137 <param index="0" name="favorites" type="PackedStringArray" />
138 <description>
139 Sets the list of favorite directories, which is shared by all [FileDialog] nodes. Useful to restore the list of favorites saved with [method get_favorite_list]. This method can be called only from the main thread.
140 [b]Note:[/b] [FileDialog] will update its internal [ItemList] of favorites when its visibility changes. Be sure to call this method earlier if you want your changes to have effect.
141 </description>
142 </method>
143 <method name="set_get_icon_callback" qualifiers="static">
144 <return type="void" />
145 <param index="0" name="callback" type="Callable" />
146 <description>
147 Sets the callback used by the [FileDialog] nodes to get a file icon, when [constant DISPLAY_LIST] mode is used. The callback should take a single [String] argument (file path), and return a [Texture2D]. If an invalid texture is returned, the [theme_item file] icon will be used instead.
148 </description>
149 </method>
150 <method name="set_get_thumbnail_callback" qualifiers="static">
151 <return type="void" />
152 <param index="0" name="callback" type="Callable" />
153 <description>
154 Sets the callback used by the [FileDialog] nodes to get a file icon, when [constant DISPLAY_THUMBNAILS] mode is used. The callback should take a single [String] argument (file path), and return a [Texture2D]. If an invalid texture is returned, the [theme_item file_thumbnail] icon will be used instead.
155 Thumbnails are usually more complex and may take a while to load. To avoid stalling the application, you can use [ImageTexture] to asynchronously create the thumbnail.
156 [codeblock]
157 func _ready():
158 FileDialog.set_get_thumbnail_callback(thumbnail_method)
159
160 func thumbnail_method(path):
161 var image_texture = ImageTexture.new()
162 make_thumbnail_async(path, image_texture)
163 return image_texture
164
165 func make_thumbnail_async(path, image_texture):
166 var thumbnail_texture = await generate_thumbnail(path) # Some method that generates a thumbnail.
167 image_texture.set_image(thumbnail_texture.get_image())
168 [/codeblock]
169 </description>
170 </method>
171 <method name="set_option_default">
172 <return type="void" />
173 <param index="0" name="option" type="int" />
174 <param index="1" name="default_value_index" type="int" />
175 <description>
176 Sets the default value index of the [OptionButton] or [CheckBox] with index [param option].
177 </description>
178 </method>
179 <method name="set_option_name">
180 <return type="void" />
181 <param index="0" name="option" type="int" />
182 <param index="1" name="name" type="String" />
183 <description>
184 Sets the name of the [OptionButton] or [CheckBox] with index [param option].
185 </description>
186 </method>
187 <method name="set_option_values">
188 <return type="void" />
189 <param index="0" name="option" type="int" />
190 <param index="1" name="values" type="PackedStringArray" />
191 <description>
192 Sets the option values of the [OptionButton] with index [param option].
193 </description>
194 </method>
195 <method name="set_recent_list" qualifiers="static">
196 <return type="void" />
197 <param index="0" name="recents" type="PackedStringArray" />
198 <description>
199 Sets the list of recent directories, which is shared by all [FileDialog] nodes. Useful to restore the list of recents saved with [method set_recent_list]. This method can be called only from the main thread.
200 [b]Note:[/b] [FileDialog] will update its internal [ItemList] of recent directories when its visibility changes. Be sure to call this method earlier if you want your changes to have effect.
201 </description>
202 </method>
203 </methods>
204 <members>
205 <member name="access" type="int" setter="set_access" getter="get_access" enum="FileDialog.Access" default="0">
206 The file system access scope.
207 [b]Warning:[/b] In Web builds, FileDialog cannot access the host file system. In sandboxed Linux and macOS environments, [member use_native_dialog] is automatically used to allow limited access to host file system.
208 </member>
209 <member name="current_dir" type="String" setter="set_current_dir" getter="get_current_dir">
210 The current working directory of the file dialog.
211 [b]Note:[/b] For native file dialogs, this property is only treated as a hint and may not be respected by specific OS implementations.
212 </member>
213 <member name="current_file" type="String" setter="set_current_file" getter="get_current_file">
214 The currently selected file of the file dialog.
215 </member>
216 <member name="current_path" type="String" setter="set_current_path" getter="get_current_path">
217 The currently selected file path of the file dialog.
218 </member>
219 <member name="deleting_enabled" type="bool" setter="set_customization_flag_enabled" getter="is_customization_flag_enabled" default="true">
220 If [code]true[/code], the context menu will show the "Delete" option, which allows moving files and folders to trash.
221 </member>
222 <member name="dialog_hide_on_ok" type="bool" setter="set_hide_on_ok" getter="get_hide_on_ok" overrides="AcceptDialog" default="false" />
223 <member name="display_mode" type="int" setter="set_display_mode" getter="get_display_mode" enum="FileDialog.DisplayMode" default="0">
224 Display mode of the dialog's file list.
225 </member>
226 <member name="favorites_enabled" type="bool" setter="set_customization_flag_enabled" getter="is_customization_flag_enabled" default="true">
227 If [code]true[/code], shows the toggle favorite button and favorite list on the left side of the dialog.
228 </member>
229 <member name="file_filter_toggle_enabled" type="bool" setter="set_customization_flag_enabled" getter="is_customization_flag_enabled" default="true">
230 If [code]true[/code], shows the toggle file filter button.
231 </member>
232 <member name="file_mode" type="int" setter="set_file_mode" getter="get_file_mode" enum="FileDialog.FileMode" default="4">
233 The dialog's open or save mode, which affects the selection behavior.
234 </member>
235 <member name="file_sort_options_enabled" type="bool" setter="set_customization_flag_enabled" getter="is_customization_flag_enabled" default="true">
236 If [code]true[/code], shows the file sorting options button.
237 </member>
238 <member name="filename_filter" type="String" setter="set_filename_filter" getter="get_filename_filter" default="&quot;&quot;">
239 The filter for file names (case-insensitive). When set to a non-empty string, only files that contains the substring will be shown. [member filename_filter] can be edited by the user with the filter button at the top of the file dialog.
240 See also [member filters], which should be used to restrict the file types that can be selected instead of [member filename_filter] which is meant to be set by the user.
241 </member>
242 <member name="filters" type="PackedStringArray" setter="set_filters" getter="get_filters" default="PackedStringArray()">
243 The available file type filters. Each filter string in the array should be formatted like this: [code]*.png,*.jpg,*.jpeg;Image Files;image/png,image/jpeg[/code]. The description text of the filter is optional and can be omitted. Both file extensions and MIME type should be always set.
244 [b]Note:[/b] Embedded file dialogs and Windows file dialogs support only file extensions, while Android, Linux, and macOS file dialogs also support MIME types.
245 </member>
246 <member name="folder_creation_enabled" type="bool" setter="set_customization_flag_enabled" getter="is_customization_flag_enabled" default="true">
247 If [code]true[/code], shows the button for creating new directories (when using [constant FILE_MODE_OPEN_DIR], [constant FILE_MODE_OPEN_ANY], or [constant FILE_MODE_SAVE_FILE]), and the context menu will have the "New Folder..." option.
248 </member>
249 <member name="hidden_files_toggle_enabled" type="bool" setter="set_customization_flag_enabled" getter="is_customization_flag_enabled" default="true">
250 If [code]true[/code], shows the toggle hidden files button.
251 </member>
252 <member name="layout_toggle_enabled" type="bool" setter="set_customization_flag_enabled" getter="is_customization_flag_enabled" default="true">
253 If [code]true[/code], shows the layout switch buttons (list/thumbnails).
254 </member>
255 <member name="mode_overrides_title" type="bool" setter="set_mode_overrides_title" getter="is_mode_overriding_title" default="true">
256 If [code]true[/code], changing the [member file_mode] property will set the window title accordingly (e.g. setting [member file_mode] to [constant FILE_MODE_OPEN_FILE] will change the window title to "Open a File").
257 </member>
258 <member name="option_count" type="int" setter="set_option_count" getter="get_option_count" default="0">
259 The number of additional [OptionButton]s and [CheckBox]es in the dialog.
260 </member>
261 <member name="overwrite_warning_enabled" type="bool" setter="set_customization_flag_enabled" getter="is_customization_flag_enabled" default="true">
262 If [code]true[/code], the [FileDialog] will warn the user before overwriting files in save mode.
263 </member>
264 <member name="recent_list_enabled" type="bool" setter="set_customization_flag_enabled" getter="is_customization_flag_enabled" default="true">
265 If [code]true[/code], shows the recent directories list on the left side of the dialog.
266 </member>
267 <member name="root_subfolder" type="String" setter="set_root_subfolder" getter="get_root_subfolder" default="&quot;&quot;">
268 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.
269 [b]Note:[/b] This property is ignored by native file dialogs.
270 </member>
271 <member name="show_hidden_files" type="bool" setter="set_show_hidden_files" getter="is_showing_hidden_files" default="false">
272 If [code]true[/code], the dialog will show hidden files.
273 [b]Note:[/b] This property is ignored by native file dialogs on Android and Linux.
274 </member>
275 <member name="size" type="Vector2i" setter="set_size" getter="get_size" overrides="Window" default="Vector2i(640, 360)" />
276 <member name="title" type="String" setter="set_title" getter="get_title" overrides="Window" default="&quot;Save a File&quot;" />
277 <member name="use_native_dialog" type="bool" setter="set_use_native_dialog" getter="get_use_native_dialog" default="false">
278 If [code]true[/code], and if supported by the current [DisplayServer], OS native dialog will be used instead of custom one.
279 [b]Note:[/b] On Android, it is only supported when using [constant ACCESS_FILESYSTEM]. For access mode [constant ACCESS_RESOURCES] and [constant ACCESS_USERDATA], the system will fall back to custom FileDialog.
280 [b]Note:[/b] On Linux and macOS, sandboxed apps always use native dialogs to access the host file system.
281 [b]Note:[/b] On macOS, sandboxed apps will save security-scoped bookmarks to retain access to the opened folders across multiple sessions. Use [method OS.get_granted_permissions] to get a list of saved bookmarks.
282 [b]Note:[/b] Native dialogs are isolated from the base process, file dialog properties can't be modified once the dialog is shown.
283 [b]Note:[/b] This property is ignored in [EditorFileDialog].
284 </member>
285 </members>
286 <signals>
287 <signal name="dir_selected">
288 <param index="0" name="dir" type="String" />
289 <description>
290 Emitted when the user selects a directory.
291 </description>
292 </signal>
293 <signal name="file_selected">
294 <param index="0" name="path" type="String" />
295 <description>
296 Emitted when the user selects a file by double-clicking it or pressing the [b]OK[/b] button.
297 </description>
298 </signal>
299 <signal name="filename_filter_changed">
300 <param index="0" name="filter" type="String" />
301 <description>
302 Emitted when the filter for file names changes.
303 </description>
304 </signal>
305 <signal name="files_selected">
306 <param index="0" name="paths" type="PackedStringArray" />
307 <description>
308 Emitted when the user selects multiple files.
309 </description>
310 </signal>
311 </signals>
312 <constants>
313 <constant name="FILE_MODE_OPEN_FILE" value="0" enum="FileMode">
314 The dialog allows selecting one, and only one file.
315 </constant>
316 <constant name="FILE_MODE_OPEN_FILES" value="1" enum="FileMode">
317 The dialog allows selecting multiple files.
318 </constant>
319 <constant name="FILE_MODE_OPEN_DIR" value="2" enum="FileMode">
320 The dialog only allows selecting a directory, disallowing the selection of any file.
321 </constant>
322 <constant name="FILE_MODE_OPEN_ANY" value="3" enum="FileMode">
323 The dialog allows selecting one file or directory.
324 </constant>
325 <constant name="FILE_MODE_SAVE_FILE" value="4" enum="FileMode">
326 The dialog will warn when a file exists.
327 </constant>
328 <constant name="ACCESS_RESOURCES" value="0" enum="Access">
329 The dialog only allows accessing files under the [Resource] path ([code]res://[/code]).
330 </constant>
331 <constant name="ACCESS_USERDATA" value="1" enum="Access">
332 The dialog only allows accessing files under user data path ([code]user://[/code]).
333 </constant>
334 <constant name="ACCESS_FILESYSTEM" value="2" enum="Access">
335 The dialog allows accessing files on the whole file system.
336 </constant>
337 <constant name="DISPLAY_THUMBNAILS" value="0" enum="DisplayMode">
338 The dialog displays files as a grid of thumbnails. Use [theme_item thumbnail_size] to adjust their size.
339 </constant>
340 <constant name="DISPLAY_LIST" value="1" enum="DisplayMode">
341 The dialog displays files as a list of filenames.
342 </constant>
343 <constant name="CUSTOMIZATION_HIDDEN_FILES" value="0" enum="Customization">
344 Toggles visibility of the favorite button, and the favorite list on the left side of the dialog.
345 Equivalent to [member hidden_files_toggle_enabled].
346 </constant>
347 <constant name="CUSTOMIZATION_CREATE_FOLDER" value="1" enum="Customization">
348 If enabled, shows the button for creating new directories (when using [constant FILE_MODE_OPEN_DIR], [constant FILE_MODE_OPEN_ANY], or [constant FILE_MODE_SAVE_FILE]).
349 Equivalent to [member folder_creation_enabled].
350 </constant>
351 <constant name="CUSTOMIZATION_FILE_FILTER" value="2" enum="Customization">
352 If enabled, shows the toggle file filter button.
353 Equivalent to [member file_filter_toggle_enabled].
354 </constant>
355 <constant name="CUSTOMIZATION_FILE_SORT" value="3" enum="Customization">
356 If enabled, shows the file sorting options button.
357 Equivalent to [member file_sort_options_enabled].
358 </constant>
359 <constant name="CUSTOMIZATION_FAVORITES" value="4" enum="Customization">
360 If enabled, shows the toggle favorite button and favorite list on the left side of the dialog.
361 Equivalent to [member favorites_enabled].
362 </constant>
363 <constant name="CUSTOMIZATION_RECENT" value="5" enum="Customization">
364 If enabled, shows the recent directories list on the left side of the dialog.
365 Equivalent to [member recent_list_enabled].
366 </constant>
367 <constant name="CUSTOMIZATION_LAYOUT" value="6" enum="Customization">
368 If enabled, shows the layout switch buttons (list/thumbnails).
369 Equivalent to [member layout_toggle_enabled].
370 </constant>
371 <constant name="CUSTOMIZATION_OVERWRITE_WARNING" value="7" enum="Customization">
372 If enabled, the [FileDialog] will warn the user before overwriting files in save mode.
373 Equivalent to [member overwrite_warning_enabled].
374 </constant>
375 <constant name="CUSTOMIZATION_DELETE" value="8" enum="Customization">
376 If enabled, the context menu will show the "Delete" option, which allows moving files and folders to trash.
377 Equivalent to [member deleting_enabled].
378 </constant>
379 </constants>
380 <theme_items>
381 <theme_item name="file_disabled_color" data_type="color" type="Color" default="Color(1, 1, 1, 0.25)">
382 The color tint for disabled files (when the [FileDialog] is used in open folder mode).
383 </theme_item>
384 <theme_item name="file_icon_color" data_type="color" type="Color" default="Color(1, 1, 1, 1)">
385 The color modulation applied to the file icon.
386 </theme_item>
387 <theme_item name="folder_icon_color" data_type="color" type="Color" default="Color(1, 1, 1, 1)">
388 The color modulation applied to the folder icon.
389 </theme_item>
390 <theme_item name="thumbnail_size" data_type="constant" type="int" default="64">
391 The size of thumbnail icons when [constant DISPLAY_THUMBNAILS] is enabled.
392 </theme_item>
393 <theme_item name="back_folder" data_type="icon" type="Texture2D">
394 Custom icon for the back arrow.
395 </theme_item>
396 <theme_item name="create_folder" data_type="icon" type="Texture2D">
397 Custom icon for the create folder button.
398 </theme_item>
399 <theme_item name="favorite" data_type="icon" type="Texture2D">
400 Custom icon for favorite folder button.
401 </theme_item>
402 <theme_item name="favorite_down" data_type="icon" type="Texture2D">
403 Custom icon for button to move down a favorite entry.
404 </theme_item>
405 <theme_item name="favorite_up" data_type="icon" type="Texture2D">
406 Custom icon for button to move up a favorite entry.
407 </theme_item>
408 <theme_item name="file" data_type="icon" type="Texture2D">
409 Custom icon for files.
410 </theme_item>
411 <theme_item name="file_thumbnail" data_type="icon" type="Texture2D">
412 Icon for files when in thumbnail mode.
413 </theme_item>
414 <theme_item name="folder" data_type="icon" type="Texture2D">
415 Custom icon for folders.
416 </theme_item>
417 <theme_item name="folder_thumbnail" data_type="icon" type="Texture2D">
418 Icon for folders when in thumbnail mode.
419 </theme_item>
420 <theme_item name="forward_folder" data_type="icon" type="Texture2D">
421 Custom icon for the forward arrow.
422 </theme_item>
423 <theme_item name="list_mode" data_type="icon" type="Texture2D">
424 Icon for the button that enables list mode.
425 </theme_item>
426 <theme_item name="parent_folder" data_type="icon" type="Texture2D">
427 Custom icon for the parent folder arrow.
428 </theme_item>
429 <theme_item name="reload" data_type="icon" type="Texture2D">
430 Custom icon for the reload button.
431 </theme_item>
432 <theme_item name="sort" data_type="icon" type="Texture2D">
433 Custom icon for the sorting options menu.
434 </theme_item>
435 <theme_item name="thumbnail_mode" data_type="icon" type="Texture2D">
436 Icon for the button that enables thumbnail mode.
437 </theme_item>
438 <theme_item name="toggle_filename_filter" data_type="icon" type="Texture2D">
439 Custom icon for the toggle button for the filter for file names.
440 </theme_item>
441 <theme_item name="toggle_hidden" data_type="icon" type="Texture2D">
442 Custom icon for the toggle hidden button.
443 </theme_item>
444 </theme_items>
445 </class>