class_filedialog.rst 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the FileDialog.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_FileDialog:
  6. FileDialog
  7. ==========
  8. **Inherits:** :ref:`ConfirmationDialog<class_ConfirmationDialog>` **<** :ref:`AcceptDialog<class_AcceptDialog>` **<** :ref:`WindowDialog<class_WindowDialog>` **<** :ref:`Popup<class_Popup>` **<** :ref:`Control<class_Control>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  9. Dialog for selecting files or directories in the filesystem.
  10. Description
  11. -----------
  12. FileDialog is a preset dialog used to choose files and directories in the filesystem. It supports filter masks.
  13. Properties
  14. ----------
  15. +---------------------------------------------------+-----------------------------------------------------------------------------+---------------------------+
  16. | :ref:`Access<enum_FileDialog_Access>` | :ref:`access<class_FileDialog_property_access>` | ``0`` |
  17. +---------------------------------------------------+-----------------------------------------------------------------------------+---------------------------+
  18. | :ref:`String<class_String>` | :ref:`current_dir<class_FileDialog_property_current_dir>` | ``"res://"`` |
  19. +---------------------------------------------------+-----------------------------------------------------------------------------+---------------------------+
  20. | :ref:`String<class_String>` | :ref:`current_file<class_FileDialog_property_current_file>` | ``""`` |
  21. +---------------------------------------------------+-----------------------------------------------------------------------------+---------------------------+
  22. | :ref:`String<class_String>` | :ref:`current_path<class_FileDialog_property_current_path>` | ``"res://"`` |
  23. +---------------------------------------------------+-----------------------------------------------------------------------------+---------------------------+
  24. | :ref:`bool<class_bool>` | dialog_hide_on_ok | **O:** ``false`` |
  25. +---------------------------------------------------+-----------------------------------------------------------------------------+---------------------------+
  26. | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`filters<class_FileDialog_property_filters>` | ``PackedStringArray( )`` |
  27. +---------------------------------------------------+-----------------------------------------------------------------------------+---------------------------+
  28. | :ref:`Mode<enum_FileDialog_Mode>` | :ref:`mode<class_FileDialog_property_mode>` | ``4`` |
  29. +---------------------------------------------------+-----------------------------------------------------------------------------+---------------------------+
  30. | :ref:`bool<class_bool>` | :ref:`mode_overrides_title<class_FileDialog_property_mode_overrides_title>` | ``true`` |
  31. +---------------------------------------------------+-----------------------------------------------------------------------------+---------------------------+
  32. | :ref:`bool<class_bool>` | :ref:`show_hidden_files<class_FileDialog_property_show_hidden_files>` | ``false`` |
  33. +---------------------------------------------------+-----------------------------------------------------------------------------+---------------------------+
  34. | :ref:`String<class_String>` | window_title | **O:** ``"Save a File"`` |
  35. +---------------------------------------------------+-----------------------------------------------------------------------------+---------------------------+
  36. Methods
  37. -------
  38. +-------------------------------------------+------------------------------------------------------------------------------------------------------+
  39. | void | :ref:`add_filter<class_FileDialog_method_add_filter>` **(** :ref:`String<class_String>` filter **)** |
  40. +-------------------------------------------+------------------------------------------------------------------------------------------------------+
  41. | void | :ref:`clear_filters<class_FileDialog_method_clear_filters>` **(** **)** |
  42. +-------------------------------------------+------------------------------------------------------------------------------------------------------+
  43. | void | :ref:`deselect_items<class_FileDialog_method_deselect_items>` **(** **)** |
  44. +-------------------------------------------+------------------------------------------------------------------------------------------------------+
  45. | :ref:`LineEdit<class_LineEdit>` | :ref:`get_line_edit<class_FileDialog_method_get_line_edit>` **(** **)** |
  46. +-------------------------------------------+------------------------------------------------------------------------------------------------------+
  47. | :ref:`VBoxContainer<class_VBoxContainer>` | :ref:`get_vbox<class_FileDialog_method_get_vbox>` **(** **)** |
  48. +-------------------------------------------+------------------------------------------------------------------------------------------------------+
  49. | void | :ref:`invalidate<class_FileDialog_method_invalidate>` **(** **)** |
  50. +-------------------------------------------+------------------------------------------------------------------------------------------------------+
  51. Theme Properties
  52. ----------------
  53. +-----------------------------------+----------------------+-----------------------+
  54. | :ref:`Color<class_Color>` | files_disabled | Color( 0, 0, 0, 0.7 ) |
  55. +-----------------------------------+----------------------+-----------------------+
  56. | :ref:`Texture2D<class_Texture2D>` | folder | |
  57. +-----------------------------------+----------------------+-----------------------+
  58. | :ref:`Color<class_Color>` | folder_icon_modulate | Color( 1, 1, 1, 1 ) |
  59. +-----------------------------------+----------------------+-----------------------+
  60. | :ref:`Texture2D<class_Texture2D>` | parent_folder | |
  61. +-----------------------------------+----------------------+-----------------------+
  62. | :ref:`Texture2D<class_Texture2D>` | reload | |
  63. +-----------------------------------+----------------------+-----------------------+
  64. | :ref:`Texture2D<class_Texture2D>` | toggle_hidden | |
  65. +-----------------------------------+----------------------+-----------------------+
  66. Signals
  67. -------
  68. .. _class_FileDialog_signal_dir_selected:
  69. - **dir_selected** **(** :ref:`String<class_String>` dir **)**
  70. Emitted when the user selects a directory.
  71. ----
  72. .. _class_FileDialog_signal_file_selected:
  73. - **file_selected** **(** :ref:`String<class_String>` path **)**
  74. Emitted when the user selects a file by double-clicking it or pressing the **OK** button.
  75. ----
  76. .. _class_FileDialog_signal_files_selected:
  77. - **files_selected** **(** :ref:`PackedStringArray<class_PackedStringArray>` paths **)**
  78. Emitted when the user selects multiple files.
  79. Enumerations
  80. ------------
  81. .. _enum_FileDialog_Mode:
  82. .. _class_FileDialog_constant_MODE_OPEN_FILE:
  83. .. _class_FileDialog_constant_MODE_OPEN_FILES:
  84. .. _class_FileDialog_constant_MODE_OPEN_DIR:
  85. .. _class_FileDialog_constant_MODE_OPEN_ANY:
  86. .. _class_FileDialog_constant_MODE_SAVE_FILE:
  87. enum **Mode**:
  88. - **MODE_OPEN_FILE** = **0** --- The dialog allows selecting one, and only one file.
  89. - **MODE_OPEN_FILES** = **1** --- The dialog allows selecting multiple files.
  90. - **MODE_OPEN_DIR** = **2** --- The dialog only allows selecting a directory, disallowing the selection of any file.
  91. - **MODE_OPEN_ANY** = **3** --- The dialog allows selecting one file or directory.
  92. - **MODE_SAVE_FILE** = **4** --- The dialog will warn when a file exists.
  93. ----
  94. .. _enum_FileDialog_Access:
  95. .. _class_FileDialog_constant_ACCESS_RESOURCES:
  96. .. _class_FileDialog_constant_ACCESS_USERDATA:
  97. .. _class_FileDialog_constant_ACCESS_FILESYSTEM:
  98. enum **Access**:
  99. - **ACCESS_RESOURCES** = **0** --- The dialog only allows accessing files under the :ref:`Resource<class_Resource>` path (``res://``).
  100. - **ACCESS_USERDATA** = **1** --- The dialog only allows accessing files under user data path (``user://``).
  101. - **ACCESS_FILESYSTEM** = **2** --- The dialog allows accessing files on the whole file system.
  102. Property Descriptions
  103. ---------------------
  104. .. _class_FileDialog_property_access:
  105. - :ref:`Access<enum_FileDialog_Access>` **access**
  106. +-----------+-------------------+
  107. | *Default* | ``0`` |
  108. +-----------+-------------------+
  109. | *Setter* | set_access(value) |
  110. +-----------+-------------------+
  111. | *Getter* | get_access() |
  112. +-----------+-------------------+
  113. The file system access scope. See enum ``Access`` constants.
  114. ----
  115. .. _class_FileDialog_property_current_dir:
  116. - :ref:`String<class_String>` **current_dir**
  117. +-----------+------------------------+
  118. | *Default* | ``"res://"`` |
  119. +-----------+------------------------+
  120. | *Setter* | set_current_dir(value) |
  121. +-----------+------------------------+
  122. | *Getter* | get_current_dir() |
  123. +-----------+------------------------+
  124. The current working directory of the file dialog.
  125. ----
  126. .. _class_FileDialog_property_current_file:
  127. - :ref:`String<class_String>` **current_file**
  128. +-----------+-------------------------+
  129. | *Default* | ``""`` |
  130. +-----------+-------------------------+
  131. | *Setter* | set_current_file(value) |
  132. +-----------+-------------------------+
  133. | *Getter* | get_current_file() |
  134. +-----------+-------------------------+
  135. The currently selected file of the file dialog.
  136. ----
  137. .. _class_FileDialog_property_current_path:
  138. - :ref:`String<class_String>` **current_path**
  139. +-----------+-------------------------+
  140. | *Default* | ``"res://"`` |
  141. +-----------+-------------------------+
  142. | *Setter* | set_current_path(value) |
  143. +-----------+-------------------------+
  144. | *Getter* | get_current_path() |
  145. +-----------+-------------------------+
  146. The currently selected file path of the file dialog.
  147. ----
  148. .. _class_FileDialog_property_filters:
  149. - :ref:`PackedStringArray<class_PackedStringArray>` **filters**
  150. +-----------+---------------------------+
  151. | *Default* | ``PackedStringArray( )`` |
  152. +-----------+---------------------------+
  153. | *Setter* | set_filters(value) |
  154. +-----------+---------------------------+
  155. | *Getter* | get_filters() |
  156. +-----------+---------------------------+
  157. The available file type filters. For example, this shows only ``.png`` and ``.gd`` files: ``set_filters(PackedStringArray(["*.png ; PNG Images","*.gd ; GDScript Files"]))``.
  158. ----
  159. .. _class_FileDialog_property_mode:
  160. - :ref:`Mode<enum_FileDialog_Mode>` **mode**
  161. +-----------+-----------------+
  162. | *Default* | ``4`` |
  163. +-----------+-----------------+
  164. | *Setter* | set_mode(value) |
  165. +-----------+-----------------+
  166. | *Getter* | get_mode() |
  167. +-----------+-----------------+
  168. The dialog's open or save mode, which affects the selection behavior. See enum ``Mode`` constants.
  169. ----
  170. .. _class_FileDialog_property_mode_overrides_title:
  171. - :ref:`bool<class_bool>` **mode_overrides_title**
  172. +-----------+---------------------------------+
  173. | *Default* | ``true`` |
  174. +-----------+---------------------------------+
  175. | *Setter* | set_mode_overrides_title(value) |
  176. +-----------+---------------------------------+
  177. | *Getter* | is_mode_overriding_title() |
  178. +-----------+---------------------------------+
  179. If ``true``, changing the ``Mode`` property will set the window title accordingly (e.g. setting mode to :ref:`MODE_OPEN_FILE<class_FileDialog_constant_MODE_OPEN_FILE>` will change the window title to "Open a File").
  180. ----
  181. .. _class_FileDialog_property_show_hidden_files:
  182. - :ref:`bool<class_bool>` **show_hidden_files**
  183. +-----------+------------------------------+
  184. | *Default* | ``false`` |
  185. +-----------+------------------------------+
  186. | *Setter* | set_show_hidden_files(value) |
  187. +-----------+------------------------------+
  188. | *Getter* | is_showing_hidden_files() |
  189. +-----------+------------------------------+
  190. If ``true``, the dialog will show hidden files.
  191. Method Descriptions
  192. -------------------
  193. .. _class_FileDialog_method_add_filter:
  194. - void **add_filter** **(** :ref:`String<class_String>` filter **)**
  195. Adds ``filter`` as a custom filter; ``filter`` should be of the form ``"filename.extension ; Description"``. For example, ``"*.png ; PNG Images"``.
  196. ----
  197. .. _class_FileDialog_method_clear_filters:
  198. - void **clear_filters** **(** **)**
  199. Clear all the added filters in the dialog.
  200. ----
  201. .. _class_FileDialog_method_deselect_items:
  202. - void **deselect_items** **(** **)**
  203. Clear currently selected items in the dialog.
  204. ----
  205. .. _class_FileDialog_method_get_line_edit:
  206. - :ref:`LineEdit<class_LineEdit>` **get_line_edit** **(** **)**
  207. Returns the LineEdit for the selected file.
  208. ----
  209. .. _class_FileDialog_method_get_vbox:
  210. - :ref:`VBoxContainer<class_VBoxContainer>` **get_vbox** **(** **)**
  211. Returns the vertical box container of the dialog, custom controls can be added to it.
  212. ----
  213. .. _class_FileDialog_method_invalidate:
  214. - void **invalidate** **(** **)**
  215. Invalidate and update the current dialog content list.