class_acceptdialog.rst 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  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/AcceptDialog.xml.
  6. .. _class_AcceptDialog:
  7. AcceptDialog
  8. ============
  9. **Inherits:** :ref:`Window<class_Window>` **<** :ref:`Viewport<class_Viewport>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. **Inherited By:** :ref:`ConfirmationDialog<class_ConfirmationDialog>`
  11. A base dialog used for user notification.
  12. .. rst-class:: classref-introduction-group
  13. Description
  14. -----------
  15. The default use of **AcceptDialog** is to allow it to only be accepted or closed, with the same result. However, the :ref:`confirmed<class_AcceptDialog_signal_confirmed>` and :ref:`canceled<class_AcceptDialog_signal_canceled>` signals allow to make the two actions different, and the :ref:`add_button()<class_AcceptDialog_method_add_button>` method allows to add custom buttons and actions.
  16. \ **Note:** **AcceptDialog** is invisible by default. To make it visible, call one of the ``popup_*`` methods from :ref:`Window<class_Window>` on the node, such as :ref:`Window.popup_centered_clamped()<class_Window_method_popup_centered_clamped>`.
  17. .. rst-class:: classref-reftable-group
  18. Properties
  19. ----------
  20. .. table::
  21. :widths: auto
  22. +-----------------------------+-----------------------------------------------------------------------------------+------------------------------------------------------------------------------+
  23. | :ref:`bool<class_bool>` | :ref:`dialog_autowrap<class_AcceptDialog_property_dialog_autowrap>` | ``false`` |
  24. +-----------------------------+-----------------------------------------------------------------------------------+------------------------------------------------------------------------------+
  25. | :ref:`bool<class_bool>` | :ref:`dialog_close_on_escape<class_AcceptDialog_property_dialog_close_on_escape>` | ``true`` |
  26. +-----------------------------+-----------------------------------------------------------------------------------+------------------------------------------------------------------------------+
  27. | :ref:`bool<class_bool>` | :ref:`dialog_hide_on_ok<class_AcceptDialog_property_dialog_hide_on_ok>` | ``true`` |
  28. +-----------------------------+-----------------------------------------------------------------------------------+------------------------------------------------------------------------------+
  29. | :ref:`String<class_String>` | :ref:`dialog_text<class_AcceptDialog_property_dialog_text>` | ``""`` |
  30. +-----------------------------+-----------------------------------------------------------------------------------+------------------------------------------------------------------------------+
  31. | :ref:`bool<class_bool>` | exclusive | ``true`` (overrides :ref:`Window<class_Window_property_exclusive>`) |
  32. +-----------------------------+-----------------------------------------------------------------------------------+------------------------------------------------------------------------------+
  33. | :ref:`bool<class_bool>` | keep_title_visible | ``true`` (overrides :ref:`Window<class_Window_property_keep_title_visible>`) |
  34. +-----------------------------+-----------------------------------------------------------------------------------+------------------------------------------------------------------------------+
  35. | :ref:`bool<class_bool>` | maximize_disabled | ``true`` (overrides :ref:`Window<class_Window_property_maximize_disabled>`) |
  36. +-----------------------------+-----------------------------------------------------------------------------------+------------------------------------------------------------------------------+
  37. | :ref:`bool<class_bool>` | minimize_disabled | ``true`` (overrides :ref:`Window<class_Window_property_minimize_disabled>`) |
  38. +-----------------------------+-----------------------------------------------------------------------------------+------------------------------------------------------------------------------+
  39. | :ref:`String<class_String>` | :ref:`ok_button_text<class_AcceptDialog_property_ok_button_text>` | ``""`` |
  40. +-----------------------------+-----------------------------------------------------------------------------------+------------------------------------------------------------------------------+
  41. | :ref:`String<class_String>` | title | ``"Alert!"`` (overrides :ref:`Window<class_Window_property_title>`) |
  42. +-----------------------------+-----------------------------------------------------------------------------------+------------------------------------------------------------------------------+
  43. | :ref:`bool<class_bool>` | transient | ``true`` (overrides :ref:`Window<class_Window_property_transient>`) |
  44. +-----------------------------+-----------------------------------------------------------------------------------+------------------------------------------------------------------------------+
  45. | :ref:`bool<class_bool>` | visible | ``false`` (overrides :ref:`Window<class_Window_property_visible>`) |
  46. +-----------------------------+-----------------------------------------------------------------------------------+------------------------------------------------------------------------------+
  47. | :ref:`bool<class_bool>` | wrap_controls | ``true`` (overrides :ref:`Window<class_Window_property_wrap_controls>`) |
  48. +-----------------------------+-----------------------------------------------------------------------------------+------------------------------------------------------------------------------+
  49. .. rst-class:: classref-reftable-group
  50. Methods
  51. -------
  52. .. table::
  53. :widths: auto
  54. +-----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | :ref:`Button<class_Button>` | :ref:`add_button<class_AcceptDialog_method_add_button>`\ (\ text\: :ref:`String<class_String>`, right\: :ref:`bool<class_bool>` = false, action\: :ref:`String<class_String>` = ""\ ) |
  56. +-----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | :ref:`Button<class_Button>` | :ref:`add_cancel_button<class_AcceptDialog_method_add_cancel_button>`\ (\ name\: :ref:`String<class_String>`\ ) |
  58. +-----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | :ref:`Label<class_Label>` | :ref:`get_label<class_AcceptDialog_method_get_label>`\ (\ ) |
  60. +-----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | :ref:`Button<class_Button>` | :ref:`get_ok_button<class_AcceptDialog_method_get_ok_button>`\ (\ ) |
  62. +-----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | |void| | :ref:`register_text_enter<class_AcceptDialog_method_register_text_enter>`\ (\ line_edit\: :ref:`LineEdit<class_LineEdit>`\ ) |
  64. +-----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | |void| | :ref:`remove_button<class_AcceptDialog_method_remove_button>`\ (\ button\: :ref:`Button<class_Button>`\ ) |
  66. +-----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. .. rst-class:: classref-reftable-group
  68. Theme Properties
  69. ----------------
  70. .. table::
  71. :widths: auto
  72. +---------------------------------+---------------------------------------------------------------------------------+--------+
  73. | :ref:`int<class_int>` | :ref:`buttons_min_height<class_AcceptDialog_theme_constant_buttons_min_height>` | ``0`` |
  74. +---------------------------------+---------------------------------------------------------------------------------+--------+
  75. | :ref:`int<class_int>` | :ref:`buttons_min_width<class_AcceptDialog_theme_constant_buttons_min_width>` | ``0`` |
  76. +---------------------------------+---------------------------------------------------------------------------------+--------+
  77. | :ref:`int<class_int>` | :ref:`buttons_separation<class_AcceptDialog_theme_constant_buttons_separation>` | ``10`` |
  78. +---------------------------------+---------------------------------------------------------------------------------+--------+
  79. | :ref:`StyleBox<class_StyleBox>` | :ref:`panel<class_AcceptDialog_theme_style_panel>` | |
  80. +---------------------------------+---------------------------------------------------------------------------------+--------+
  81. .. rst-class:: classref-section-separator
  82. ----
  83. .. rst-class:: classref-descriptions-group
  84. Signals
  85. -------
  86. .. _class_AcceptDialog_signal_canceled:
  87. .. rst-class:: classref-signal
  88. **canceled**\ (\ ) :ref:`🔗<class_AcceptDialog_signal_canceled>`
  89. Emitted when the dialog is closed or the button created with :ref:`add_cancel_button()<class_AcceptDialog_method_add_cancel_button>` is pressed.
  90. .. rst-class:: classref-item-separator
  91. ----
  92. .. _class_AcceptDialog_signal_confirmed:
  93. .. rst-class:: classref-signal
  94. **confirmed**\ (\ ) :ref:`🔗<class_AcceptDialog_signal_confirmed>`
  95. Emitted when the dialog is accepted, i.e. the OK button is pressed.
  96. .. rst-class:: classref-item-separator
  97. ----
  98. .. _class_AcceptDialog_signal_custom_action:
  99. .. rst-class:: classref-signal
  100. **custom_action**\ (\ action\: :ref:`StringName<class_StringName>`\ ) :ref:`🔗<class_AcceptDialog_signal_custom_action>`
  101. Emitted when a custom button with an action is pressed. See :ref:`add_button()<class_AcceptDialog_method_add_button>`.
  102. .. rst-class:: classref-section-separator
  103. ----
  104. .. rst-class:: classref-descriptions-group
  105. Property Descriptions
  106. ---------------------
  107. .. _class_AcceptDialog_property_dialog_autowrap:
  108. .. rst-class:: classref-property
  109. :ref:`bool<class_bool>` **dialog_autowrap** = ``false`` :ref:`🔗<class_AcceptDialog_property_dialog_autowrap>`
  110. .. rst-class:: classref-property-setget
  111. - |void| **set_autowrap**\ (\ value\: :ref:`bool<class_bool>`\ )
  112. - :ref:`bool<class_bool>` **has_autowrap**\ (\ )
  113. Sets autowrapping for the text in the dialog.
  114. .. rst-class:: classref-item-separator
  115. ----
  116. .. _class_AcceptDialog_property_dialog_close_on_escape:
  117. .. rst-class:: classref-property
  118. :ref:`bool<class_bool>` **dialog_close_on_escape** = ``true`` :ref:`🔗<class_AcceptDialog_property_dialog_close_on_escape>`
  119. .. rst-class:: classref-property-setget
  120. - |void| **set_close_on_escape**\ (\ value\: :ref:`bool<class_bool>`\ )
  121. - :ref:`bool<class_bool>` **get_close_on_escape**\ (\ )
  122. If ``true``, the dialog will be hidden when the ``ui_close_dialog`` action is pressed (by default, this action is bound to :kbd:`Escape`, or :kbd:`Cmd + W` on macOS).
  123. .. rst-class:: classref-item-separator
  124. ----
  125. .. _class_AcceptDialog_property_dialog_hide_on_ok:
  126. .. rst-class:: classref-property
  127. :ref:`bool<class_bool>` **dialog_hide_on_ok** = ``true`` :ref:`🔗<class_AcceptDialog_property_dialog_hide_on_ok>`
  128. .. rst-class:: classref-property-setget
  129. - |void| **set_hide_on_ok**\ (\ value\: :ref:`bool<class_bool>`\ )
  130. - :ref:`bool<class_bool>` **get_hide_on_ok**\ (\ )
  131. If ``true``, the dialog is hidden when the OK button is pressed. You can set it to ``false`` if you want to do e.g. input validation when receiving the :ref:`confirmed<class_AcceptDialog_signal_confirmed>` signal, and handle hiding the dialog in your own logic.
  132. \ **Note:** Some nodes derived from this class can have a different default value, and potentially their own built-in logic overriding this setting. For example :ref:`FileDialog<class_FileDialog>` defaults to ``false``, and has its own input validation code that is called when you press OK, which eventually hides the dialog if the input is valid. As such, this property can't be used in :ref:`FileDialog<class_FileDialog>` to disable hiding the dialog when pressing OK.
  133. .. rst-class:: classref-item-separator
  134. ----
  135. .. _class_AcceptDialog_property_dialog_text:
  136. .. rst-class:: classref-property
  137. :ref:`String<class_String>` **dialog_text** = ``""`` :ref:`🔗<class_AcceptDialog_property_dialog_text>`
  138. .. rst-class:: classref-property-setget
  139. - |void| **set_text**\ (\ value\: :ref:`String<class_String>`\ )
  140. - :ref:`String<class_String>` **get_text**\ (\ )
  141. The text displayed by the dialog.
  142. .. rst-class:: classref-item-separator
  143. ----
  144. .. _class_AcceptDialog_property_ok_button_text:
  145. .. rst-class:: classref-property
  146. :ref:`String<class_String>` **ok_button_text** = ``""`` :ref:`🔗<class_AcceptDialog_property_ok_button_text>`
  147. .. rst-class:: classref-property-setget
  148. - |void| **set_ok_button_text**\ (\ value\: :ref:`String<class_String>`\ )
  149. - :ref:`String<class_String>` **get_ok_button_text**\ (\ )
  150. The text displayed by the OK button (see :ref:`get_ok_button()<class_AcceptDialog_method_get_ok_button>`). If empty, a default text will be used.
  151. .. rst-class:: classref-section-separator
  152. ----
  153. .. rst-class:: classref-descriptions-group
  154. Method Descriptions
  155. -------------------
  156. .. _class_AcceptDialog_method_add_button:
  157. .. rst-class:: classref-method
  158. :ref:`Button<class_Button>` **add_button**\ (\ text\: :ref:`String<class_String>`, right\: :ref:`bool<class_bool>` = false, action\: :ref:`String<class_String>` = ""\ ) :ref:`🔗<class_AcceptDialog_method_add_button>`
  159. Adds a button with label ``text`` and a custom ``action`` to the dialog and returns the created button.
  160. If ``action`` is not empty, pressing the button will emit the :ref:`custom_action<class_AcceptDialog_signal_custom_action>` signal with the specified action string.
  161. If ``true``, ``right`` will place the button to the right of any sibling buttons.
  162. You can use :ref:`remove_button()<class_AcceptDialog_method_remove_button>` method to remove a button created with this method from the dialog.
  163. .. rst-class:: classref-item-separator
  164. ----
  165. .. _class_AcceptDialog_method_add_cancel_button:
  166. .. rst-class:: classref-method
  167. :ref:`Button<class_Button>` **add_cancel_button**\ (\ name\: :ref:`String<class_String>`\ ) :ref:`🔗<class_AcceptDialog_method_add_cancel_button>`
  168. Adds a button with label ``name`` and a cancel action to the dialog and returns the created button.
  169. You can use :ref:`remove_button()<class_AcceptDialog_method_remove_button>` method to remove a button created with this method from the dialog.
  170. .. rst-class:: classref-item-separator
  171. ----
  172. .. _class_AcceptDialog_method_get_label:
  173. .. rst-class:: classref-method
  174. :ref:`Label<class_Label>` **get_label**\ (\ ) :ref:`🔗<class_AcceptDialog_method_get_label>`
  175. Returns the label used for built-in text.
  176. \ **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.
  177. .. rst-class:: classref-item-separator
  178. ----
  179. .. _class_AcceptDialog_method_get_ok_button:
  180. .. rst-class:: classref-method
  181. :ref:`Button<class_Button>` **get_ok_button**\ (\ ) :ref:`🔗<class_AcceptDialog_method_get_ok_button>`
  182. Returns the OK :ref:`Button<class_Button>` instance.
  183. \ **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.
  184. .. rst-class:: classref-item-separator
  185. ----
  186. .. _class_AcceptDialog_method_register_text_enter:
  187. .. rst-class:: classref-method
  188. |void| **register_text_enter**\ (\ line_edit\: :ref:`LineEdit<class_LineEdit>`\ ) :ref:`🔗<class_AcceptDialog_method_register_text_enter>`
  189. Registers a :ref:`LineEdit<class_LineEdit>` in the dialog. When the enter key is pressed, the dialog will be accepted.
  190. .. rst-class:: classref-item-separator
  191. ----
  192. .. _class_AcceptDialog_method_remove_button:
  193. .. rst-class:: classref-method
  194. |void| **remove_button**\ (\ button\: :ref:`Button<class_Button>`\ ) :ref:`🔗<class_AcceptDialog_method_remove_button>`
  195. Removes the ``button`` from the dialog. Does NOT free the ``button``. The ``button`` must be a :ref:`Button<class_Button>` added with :ref:`add_button()<class_AcceptDialog_method_add_button>` or :ref:`add_cancel_button()<class_AcceptDialog_method_add_cancel_button>` method. After removal, pressing the ``button`` will no longer emit this dialog's :ref:`custom_action<class_AcceptDialog_signal_custom_action>` or :ref:`canceled<class_AcceptDialog_signal_canceled>` signals.
  196. .. rst-class:: classref-section-separator
  197. ----
  198. .. rst-class:: classref-descriptions-group
  199. Theme Property Descriptions
  200. ---------------------------
  201. .. _class_AcceptDialog_theme_constant_buttons_min_height:
  202. .. rst-class:: classref-themeproperty
  203. :ref:`int<class_int>` **buttons_min_height** = ``0`` :ref:`🔗<class_AcceptDialog_theme_constant_buttons_min_height>`
  204. The minimum height of each button in the bottom row (such as OK/Cancel) in pixels. This can be increased to make buttons with short texts easier to click/tap.
  205. .. rst-class:: classref-item-separator
  206. ----
  207. .. _class_AcceptDialog_theme_constant_buttons_min_width:
  208. .. rst-class:: classref-themeproperty
  209. :ref:`int<class_int>` **buttons_min_width** = ``0`` :ref:`🔗<class_AcceptDialog_theme_constant_buttons_min_width>`
  210. The minimum width of each button in the bottom row (such as OK/Cancel) in pixels. This can be increased to make buttons with short texts easier to click/tap.
  211. .. rst-class:: classref-item-separator
  212. ----
  213. .. _class_AcceptDialog_theme_constant_buttons_separation:
  214. .. rst-class:: classref-themeproperty
  215. :ref:`int<class_int>` **buttons_separation** = ``10`` :ref:`🔗<class_AcceptDialog_theme_constant_buttons_separation>`
  216. The size of the vertical space between the dialog's content and the button row.
  217. .. rst-class:: classref-item-separator
  218. ----
  219. .. _class_AcceptDialog_theme_style_panel:
  220. .. rst-class:: classref-themeproperty
  221. :ref:`StyleBox<class_StyleBox>` **panel** :ref:`🔗<class_AcceptDialog_theme_style_panel>`
  222. The panel that fills the background of the window.
  223. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  224. .. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)`
  225. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  226. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  227. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  228. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  229. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  230. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  231. .. |void| replace:: :abbr:`void (No return value.)`