class_filedialog.rst 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/FileDialog.xml.
  6. .. _class_FileDialog:
  7. FileDialog
  8. ==========
  9. **Inherits:** :ref:`ConfirmationDialog<class_ConfirmationDialog>` **<** :ref:`AcceptDialog<class_AcceptDialog>` **<** :ref:`Window<class_Window>` **<** :ref:`Viewport<class_Viewport>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. Dialog for selecting files or directories in the filesystem.
  11. Description
  12. -----------
  13. FileDialog is a preset dialog used to choose files and directories in the filesystem. It supports filter masks. The FileDialog automatically sets its window title according to the :ref:`file_mode<class_FileDialog_property_file_mode>`. If you want to use a custom title, disable this by setting :ref:`mode_overrides_title<class_FileDialog_property_mode_overrides_title>` to ``false``.
  14. Properties
  15. ----------
  16. +---------------------------------------------------+-----------------------------------------------------------------------------+------------------------------------------------------------------------------------------+
  17. | :ref:`Access<enum_FileDialog_Access>` | :ref:`access<class_FileDialog_property_access>` | ``0`` |
  18. +---------------------------------------------------+-----------------------------------------------------------------------------+------------------------------------------------------------------------------------------+
  19. | :ref:`String<class_String>` | :ref:`current_dir<class_FileDialog_property_current_dir>` | |
  20. +---------------------------------------------------+-----------------------------------------------------------------------------+------------------------------------------------------------------------------------------+
  21. | :ref:`String<class_String>` | :ref:`current_file<class_FileDialog_property_current_file>` | |
  22. +---------------------------------------------------+-----------------------------------------------------------------------------+------------------------------------------------------------------------------------------+
  23. | :ref:`String<class_String>` | :ref:`current_path<class_FileDialog_property_current_path>` | |
  24. +---------------------------------------------------+-----------------------------------------------------------------------------+------------------------------------------------------------------------------------------+
  25. | :ref:`bool<class_bool>` | dialog_hide_on_ok | ``false`` (overrides :ref:`AcceptDialog<class_AcceptDialog_property_dialog_hide_on_ok>`) |
  26. +---------------------------------------------------+-----------------------------------------------------------------------------+------------------------------------------------------------------------------------------+
  27. | :ref:`FileMode<enum_FileDialog_FileMode>` | :ref:`file_mode<class_FileDialog_property_file_mode>` | ``4`` |
  28. +---------------------------------------------------+-----------------------------------------------------------------------------+------------------------------------------------------------------------------------------+
  29. | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`filters<class_FileDialog_property_filters>` | ``PackedStringArray()`` |
  30. +---------------------------------------------------+-----------------------------------------------------------------------------+------------------------------------------------------------------------------------------+
  31. | :ref:`bool<class_bool>` | :ref:`mode_overrides_title<class_FileDialog_property_mode_overrides_title>` | ``true`` |
  32. +---------------------------------------------------+-----------------------------------------------------------------------------+------------------------------------------------------------------------------------------+
  33. | :ref:`String<class_String>` | :ref:`root_subfolder<class_FileDialog_property_root_subfolder>` | ``""`` |
  34. +---------------------------------------------------+-----------------------------------------------------------------------------+------------------------------------------------------------------------------------------+
  35. | :ref:`bool<class_bool>` | :ref:`show_hidden_files<class_FileDialog_property_show_hidden_files>` | ``false`` |
  36. +---------------------------------------------------+-----------------------------------------------------------------------------+------------------------------------------------------------------------------------------+
  37. | :ref:`String<class_String>` | title | ``"Save a File"`` (overrides :ref:`Window<class_Window_property_title>`) |
  38. +---------------------------------------------------+-----------------------------------------------------------------------------+------------------------------------------------------------------------------------------+
  39. Methods
  40. -------
  41. +-------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | void | :ref:`add_filter<class_FileDialog_method_add_filter>` **(** :ref:`String<class_String>` filter, :ref:`String<class_String>` description="" **)** |
  43. +-------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | void | :ref:`clear_filters<class_FileDialog_method_clear_filters>` **(** **)** |
  45. +-------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | void | :ref:`deselect_all<class_FileDialog_method_deselect_all>` **(** **)** |
  47. +-------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | :ref:`LineEdit<class_LineEdit>` | :ref:`get_line_edit<class_FileDialog_method_get_line_edit>` **(** **)** |
  49. +-------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | :ref:`VBoxContainer<class_VBoxContainer>` | :ref:`get_vbox<class_FileDialog_method_get_vbox>` **(** **)** |
  51. +-------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | void | :ref:`invalidate<class_FileDialog_method_invalidate>` **(** **)** |
  53. +-------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------+
  54. Theme Properties
  55. ----------------
  56. +-----------------------------------+--------------------------------------------------------------------------------+--------------------------+
  57. | :ref:`Color<class_Color>` | :ref:`file_icon_modulate<class_FileDialog_theme_color_file_icon_modulate>` | ``Color(1, 1, 1, 1)`` |
  58. +-----------------------------------+--------------------------------------------------------------------------------+--------------------------+
  59. | :ref:`Color<class_Color>` | :ref:`files_disabled<class_FileDialog_theme_color_files_disabled>` | ``Color(1, 1, 1, 0.25)`` |
  60. +-----------------------------------+--------------------------------------------------------------------------------+--------------------------+
  61. | :ref:`Color<class_Color>` | :ref:`folder_icon_modulate<class_FileDialog_theme_color_folder_icon_modulate>` | ``Color(1, 1, 1, 1)`` |
  62. +-----------------------------------+--------------------------------------------------------------------------------+--------------------------+
  63. | :ref:`Texture2D<class_Texture2D>` | :ref:`back_folder<class_FileDialog_theme_icon_back_folder>` | |
  64. +-----------------------------------+--------------------------------------------------------------------------------+--------------------------+
  65. | :ref:`Texture2D<class_Texture2D>` | :ref:`file<class_FileDialog_theme_icon_file>` | |
  66. +-----------------------------------+--------------------------------------------------------------------------------+--------------------------+
  67. | :ref:`Texture2D<class_Texture2D>` | :ref:`folder<class_FileDialog_theme_icon_folder>` | |
  68. +-----------------------------------+--------------------------------------------------------------------------------+--------------------------+
  69. | :ref:`Texture2D<class_Texture2D>` | :ref:`forward_folder<class_FileDialog_theme_icon_forward_folder>` | |
  70. +-----------------------------------+--------------------------------------------------------------------------------+--------------------------+
  71. | :ref:`Texture2D<class_Texture2D>` | :ref:`parent_folder<class_FileDialog_theme_icon_parent_folder>` | |
  72. +-----------------------------------+--------------------------------------------------------------------------------+--------------------------+
  73. | :ref:`Texture2D<class_Texture2D>` | :ref:`reload<class_FileDialog_theme_icon_reload>` | |
  74. +-----------------------------------+--------------------------------------------------------------------------------+--------------------------+
  75. | :ref:`Texture2D<class_Texture2D>` | :ref:`toggle_hidden<class_FileDialog_theme_icon_toggle_hidden>` | |
  76. +-----------------------------------+--------------------------------------------------------------------------------+--------------------------+
  77. Signals
  78. -------
  79. .. _class_FileDialog_signal_dir_selected:
  80. - **dir_selected** **(** :ref:`String<class_String>` dir **)**
  81. Emitted when the user selects a directory.
  82. ----
  83. .. _class_FileDialog_signal_file_selected:
  84. - **file_selected** **(** :ref:`String<class_String>` path **)**
  85. Emitted when the user selects a file by double-clicking it or pressing the **OK** button.
  86. ----
  87. .. _class_FileDialog_signal_files_selected:
  88. - **files_selected** **(** :ref:`PackedStringArray<class_PackedStringArray>` paths **)**
  89. Emitted when the user selects multiple files.
  90. Enumerations
  91. ------------
  92. .. _enum_FileDialog_FileMode:
  93. .. _class_FileDialog_constant_FILE_MODE_OPEN_FILE:
  94. .. _class_FileDialog_constant_FILE_MODE_OPEN_FILES:
  95. .. _class_FileDialog_constant_FILE_MODE_OPEN_DIR:
  96. .. _class_FileDialog_constant_FILE_MODE_OPEN_ANY:
  97. .. _class_FileDialog_constant_FILE_MODE_SAVE_FILE:
  98. enum **FileMode**:
  99. - **FILE_MODE_OPEN_FILE** = **0** --- The dialog allows selecting one, and only one file.
  100. - **FILE_MODE_OPEN_FILES** = **1** --- The dialog allows selecting multiple files.
  101. - **FILE_MODE_OPEN_DIR** = **2** --- The dialog only allows selecting a directory, disallowing the selection of any file.
  102. - **FILE_MODE_OPEN_ANY** = **3** --- The dialog allows selecting one file or directory.
  103. - **FILE_MODE_SAVE_FILE** = **4** --- The dialog will warn when a file exists.
  104. ----
  105. .. _enum_FileDialog_Access:
  106. .. _class_FileDialog_constant_ACCESS_RESOURCES:
  107. .. _class_FileDialog_constant_ACCESS_USERDATA:
  108. .. _class_FileDialog_constant_ACCESS_FILESYSTEM:
  109. enum **Access**:
  110. - **ACCESS_RESOURCES** = **0** --- The dialog only allows accessing files under the :ref:`Resource<class_Resource>` path (``res://``).
  111. - **ACCESS_USERDATA** = **1** --- The dialog only allows accessing files under user data path (``user://``).
  112. - **ACCESS_FILESYSTEM** = **2** --- The dialog allows accessing files on the whole file system.
  113. Property Descriptions
  114. ---------------------
  115. .. _class_FileDialog_property_access:
  116. - :ref:`Access<enum_FileDialog_Access>` **access**
  117. +-----------+-------------------+
  118. | *Default* | ``0`` |
  119. +-----------+-------------------+
  120. | *Setter* | set_access(value) |
  121. +-----------+-------------------+
  122. | *Getter* | get_access() |
  123. +-----------+-------------------+
  124. The file system access scope. See enum ``Access`` constants.
  125. \ **Warning:** Currently, in sandboxed environments such as HTML5 builds or sandboxed macOS apps, FileDialog cannot access the host file system. See `godot-proposals#1123 <https://github.com/godotengine/godot-proposals/issues/1123>`__.
  126. ----
  127. .. _class_FileDialog_property_current_dir:
  128. - :ref:`String<class_String>` **current_dir**
  129. +----------+------------------------+
  130. | *Setter* | set_current_dir(value) |
  131. +----------+------------------------+
  132. | *Getter* | get_current_dir() |
  133. +----------+------------------------+
  134. The current working directory of the file dialog.
  135. ----
  136. .. _class_FileDialog_property_current_file:
  137. - :ref:`String<class_String>` **current_file**
  138. +----------+-------------------------+
  139. | *Setter* | set_current_file(value) |
  140. +----------+-------------------------+
  141. | *Getter* | get_current_file() |
  142. +----------+-------------------------+
  143. The currently selected file of the file dialog.
  144. ----
  145. .. _class_FileDialog_property_current_path:
  146. - :ref:`String<class_String>` **current_path**
  147. +----------+-------------------------+
  148. | *Setter* | set_current_path(value) |
  149. +----------+-------------------------+
  150. | *Getter* | get_current_path() |
  151. +----------+-------------------------+
  152. The currently selected file path of the file dialog.
  153. ----
  154. .. _class_FileDialog_property_file_mode:
  155. - :ref:`FileMode<enum_FileDialog_FileMode>` **file_mode**
  156. +-----------+----------------------+
  157. | *Default* | ``4`` |
  158. +-----------+----------------------+
  159. | *Setter* | set_file_mode(value) |
  160. +-----------+----------------------+
  161. | *Getter* | get_file_mode() |
  162. +-----------+----------------------+
  163. The dialog's open or save mode, which affects the selection behavior. See :ref:`FileMode<enum_FileDialog_FileMode>`.
  164. ----
  165. .. _class_FileDialog_property_filters:
  166. - :ref:`PackedStringArray<class_PackedStringArray>` **filters**
  167. +-----------+-------------------------+
  168. | *Default* | ``PackedStringArray()`` |
  169. +-----------+-------------------------+
  170. | *Setter* | set_filters(value) |
  171. +-----------+-------------------------+
  172. | *Getter* | get_filters() |
  173. +-----------+-------------------------+
  174. 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.
  175. ----
  176. .. _class_FileDialog_property_mode_overrides_title:
  177. - :ref:`bool<class_bool>` **mode_overrides_title**
  178. +-----------+---------------------------------+
  179. | *Default* | ``true`` |
  180. +-----------+---------------------------------+
  181. | *Setter* | set_mode_overrides_title(value) |
  182. +-----------+---------------------------------+
  183. | *Getter* | is_mode_overriding_title() |
  184. +-----------+---------------------------------+
  185. If ``true``, changing the ``Mode`` property will set the window title accordingly (e.g. setting mode to :ref:`FILE_MODE_OPEN_FILE<class_FileDialog_constant_FILE_MODE_OPEN_FILE>` will change the window title to "Open a File").
  186. ----
  187. .. _class_FileDialog_property_root_subfolder:
  188. - :ref:`String<class_String>` **root_subfolder**
  189. +-----------+---------------------------+
  190. | *Default* | ``""`` |
  191. +-----------+---------------------------+
  192. | *Setter* | set_root_subfolder(value) |
  193. +-----------+---------------------------+
  194. | *Getter* | get_root_subfolder() |
  195. +-----------+---------------------------+
  196. 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.
  197. ----
  198. .. _class_FileDialog_property_show_hidden_files:
  199. - :ref:`bool<class_bool>` **show_hidden_files**
  200. +-----------+------------------------------+
  201. | *Default* | ``false`` |
  202. +-----------+------------------------------+
  203. | *Setter* | set_show_hidden_files(value) |
  204. +-----------+------------------------------+
  205. | *Getter* | is_showing_hidden_files() |
  206. +-----------+------------------------------+
  207. If ``true``, the dialog will show hidden files.
  208. Method Descriptions
  209. -------------------
  210. .. _class_FileDialog_method_add_filter:
  211. - void **add_filter** **(** :ref:`String<class_String>` filter, :ref:`String<class_String>` description="" **)**
  212. Adds a comma-delimited file name ``filter`` option to the ``FileDialog`` with an optional ``description``, which restricts what files can be picked.
  213. 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.
  214. For example, a ``filter`` of ``"*.png, *.jpg"`` and a ``description`` of ``"Images"`` results in filter text "Images (\*.png, \*.jpg)".
  215. ----
  216. .. _class_FileDialog_method_clear_filters:
  217. - void **clear_filters** **(** **)**
  218. Clear all the added filters in the dialog.
  219. ----
  220. .. _class_FileDialog_method_deselect_all:
  221. - void **deselect_all** **(** **)**
  222. Clear all currently selected items in the dialog.
  223. ----
  224. .. _class_FileDialog_method_get_line_edit:
  225. - :ref:`LineEdit<class_LineEdit>` **get_line_edit** **(** **)**
  226. Returns the LineEdit for the selected file.
  227. \ **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 :ref:`CanvasItem.visible<class_CanvasItem_property_visible>` property.
  228. ----
  229. .. _class_FileDialog_method_get_vbox:
  230. - :ref:`VBoxContainer<class_VBoxContainer>` **get_vbox** **(** **)**
  231. Returns the vertical box container of the dialog, custom controls can be added to it.
  232. \ **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 :ref:`CanvasItem.visible<class_CanvasItem_property_visible>` property.
  233. ----
  234. .. _class_FileDialog_method_invalidate:
  235. - void **invalidate** **(** **)**
  236. Invalidate and update the current dialog content list.
  237. Theme Property Descriptions
  238. ---------------------------
  239. .. _class_FileDialog_theme_color_file_icon_modulate:
  240. - :ref:`Color<class_Color>` **file_icon_modulate**
  241. +-----------+-----------------------+
  242. | *Default* | ``Color(1, 1, 1, 1)`` |
  243. +-----------+-----------------------+
  244. The color modulation applied to the file icon.
  245. ----
  246. .. _class_FileDialog_theme_color_files_disabled:
  247. - :ref:`Color<class_Color>` **files_disabled**
  248. +-----------+--------------------------+
  249. | *Default* | ``Color(1, 1, 1, 0.25)`` |
  250. +-----------+--------------------------+
  251. The color tint for disabled files (when the ``FileDialog`` is used in open folder mode).
  252. ----
  253. .. _class_FileDialog_theme_color_folder_icon_modulate:
  254. - :ref:`Color<class_Color>` **folder_icon_modulate**
  255. +-----------+-----------------------+
  256. | *Default* | ``Color(1, 1, 1, 1)`` |
  257. +-----------+-----------------------+
  258. The color modulation applied to the folder icon.
  259. ----
  260. .. _class_FileDialog_theme_icon_back_folder:
  261. - :ref:`Texture2D<class_Texture2D>` **back_folder**
  262. Custom icon for the back arrow.
  263. ----
  264. .. _class_FileDialog_theme_icon_file:
  265. - :ref:`Texture2D<class_Texture2D>` **file**
  266. Custom icon for files.
  267. ----
  268. .. _class_FileDialog_theme_icon_folder:
  269. - :ref:`Texture2D<class_Texture2D>` **folder**
  270. Custom icon for folders.
  271. ----
  272. .. _class_FileDialog_theme_icon_forward_folder:
  273. - :ref:`Texture2D<class_Texture2D>` **forward_folder**
  274. Custom icon for the forward arrow.
  275. ----
  276. .. _class_FileDialog_theme_icon_parent_folder:
  277. - :ref:`Texture2D<class_Texture2D>` **parent_folder**
  278. Custom icon for the parent folder arrow.
  279. ----
  280. .. _class_FileDialog_theme_icon_reload:
  281. - :ref:`Texture2D<class_Texture2D>` **reload**
  282. Custom icon for the reload button.
  283. ----
  284. .. _class_FileDialog_theme_icon_toggle_hidden:
  285. - :ref:`Texture2D<class_Texture2D>` **toggle_hidden**
  286. Custom icon for the toggle hidden button.
  287. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  288. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  289. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  290. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  291. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  292. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`