class_acceptdialog.rst 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  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. .. rst-class:: classref-reftable-group
  17. Properties
  18. ----------
  19. .. table::
  20. :widths: auto
  21. +-----------------------------+-----------------------------------------------------------------------------------+------------------------------------------------------------------------------+
  22. | :ref:`bool<class_bool>` | :ref:`dialog_autowrap<class_AcceptDialog_property_dialog_autowrap>` | ``false`` |
  23. +-----------------------------+-----------------------------------------------------------------------------------+------------------------------------------------------------------------------+
  24. | :ref:`bool<class_bool>` | :ref:`dialog_close_on_escape<class_AcceptDialog_property_dialog_close_on_escape>` | ``true`` |
  25. +-----------------------------+-----------------------------------------------------------------------------------+------------------------------------------------------------------------------+
  26. | :ref:`bool<class_bool>` | :ref:`dialog_hide_on_ok<class_AcceptDialog_property_dialog_hide_on_ok>` | ``true`` |
  27. +-----------------------------+-----------------------------------------------------------------------------------+------------------------------------------------------------------------------+
  28. | :ref:`String<class_String>` | :ref:`dialog_text<class_AcceptDialog_property_dialog_text>` | ``""`` |
  29. +-----------------------------+-----------------------------------------------------------------------------------+------------------------------------------------------------------------------+
  30. | :ref:`bool<class_bool>` | exclusive | ``true`` (overrides :ref:`Window<class_Window_property_exclusive>`) |
  31. +-----------------------------+-----------------------------------------------------------------------------------+------------------------------------------------------------------------------+
  32. | :ref:`bool<class_bool>` | keep_title_visible | ``true`` (overrides :ref:`Window<class_Window_property_keep_title_visible>`) |
  33. +-----------------------------+-----------------------------------------------------------------------------------+------------------------------------------------------------------------------+
  34. | :ref:`bool<class_bool>` | maximize_disabled | ``true`` (overrides :ref:`Window<class_Window_property_maximize_disabled>`) |
  35. +-----------------------------+-----------------------------------------------------------------------------------+------------------------------------------------------------------------------+
  36. | :ref:`bool<class_bool>` | minimize_disabled | ``true`` (overrides :ref:`Window<class_Window_property_minimize_disabled>`) |
  37. +-----------------------------+-----------------------------------------------------------------------------------+------------------------------------------------------------------------------+
  38. | :ref:`String<class_String>` | :ref:`ok_button_text<class_AcceptDialog_property_ok_button_text>` | ``""`` |
  39. +-----------------------------+-----------------------------------------------------------------------------------+------------------------------------------------------------------------------+
  40. | :ref:`String<class_String>` | title | ``"Alert!"`` (overrides :ref:`Window<class_Window_property_title>`) |
  41. +-----------------------------+-----------------------------------------------------------------------------------+------------------------------------------------------------------------------+
  42. | :ref:`bool<class_bool>` | transient | ``true`` (overrides :ref:`Window<class_Window_property_transient>`) |
  43. +-----------------------------+-----------------------------------------------------------------------------------+------------------------------------------------------------------------------+
  44. | :ref:`bool<class_bool>` | visible | ``false`` (overrides :ref:`Window<class_Window_property_visible>`) |
  45. +-----------------------------+-----------------------------------------------------------------------------------+------------------------------------------------------------------------------+
  46. | :ref:`bool<class_bool>` | wrap_controls | ``true`` (overrides :ref:`Window<class_Window_property_wrap_controls>`) |
  47. +-----------------------------+-----------------------------------------------------------------------------------+------------------------------------------------------------------------------+
  48. .. rst-class:: classref-reftable-group
  49. Methods
  50. -------
  51. .. table::
  52. :widths: auto
  53. +-----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | :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>` = ""\ ) |
  55. +-----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | :ref:`Button<class_Button>` | :ref:`add_cancel_button<class_AcceptDialog_method_add_cancel_button>`\ (\ name\: :ref:`String<class_String>`\ ) |
  57. +-----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | :ref:`Label<class_Label>` | :ref:`get_label<class_AcceptDialog_method_get_label>`\ (\ ) |
  59. +-----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | :ref:`Button<class_Button>` | :ref:`get_ok_button<class_AcceptDialog_method_get_ok_button>`\ (\ ) |
  61. +-----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | |void| | :ref:`register_text_enter<class_AcceptDialog_method_register_text_enter>`\ (\ line_edit\: :ref:`LineEdit<class_LineEdit>`\ ) |
  63. +-----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | |void| | :ref:`remove_button<class_AcceptDialog_method_remove_button>`\ (\ button\: :ref:`Button<class_Button>`\ ) |
  65. +-----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. .. rst-class:: classref-reftable-group
  67. Theme Properties
  68. ----------------
  69. .. table::
  70. :widths: auto
  71. +---------------------------------+---------------------------------------------------------------------------------+--------+
  72. | :ref:`int<class_int>` | :ref:`buttons_min_height<class_AcceptDialog_theme_constant_buttons_min_height>` | ``0`` |
  73. +---------------------------------+---------------------------------------------------------------------------------+--------+
  74. | :ref:`int<class_int>` | :ref:`buttons_min_width<class_AcceptDialog_theme_constant_buttons_min_width>` | ``0`` |
  75. +---------------------------------+---------------------------------------------------------------------------------+--------+
  76. | :ref:`int<class_int>` | :ref:`buttons_separation<class_AcceptDialog_theme_constant_buttons_separation>` | ``10`` |
  77. +---------------------------------+---------------------------------------------------------------------------------+--------+
  78. | :ref:`StyleBox<class_StyleBox>` | :ref:`panel<class_AcceptDialog_theme_style_panel>` | |
  79. +---------------------------------+---------------------------------------------------------------------------------+--------+
  80. .. rst-class:: classref-section-separator
  81. ----
  82. .. rst-class:: classref-descriptions-group
  83. Signals
  84. -------
  85. .. _class_AcceptDialog_signal_canceled:
  86. .. rst-class:: classref-signal
  87. **canceled**\ (\ ) :ref:`🔗<class_AcceptDialog_signal_canceled>`
  88. Emitted when the dialog is closed or the button created with :ref:`add_cancel_button()<class_AcceptDialog_method_add_cancel_button>` is pressed.
  89. .. rst-class:: classref-item-separator
  90. ----
  91. .. _class_AcceptDialog_signal_confirmed:
  92. .. rst-class:: classref-signal
  93. **confirmed**\ (\ ) :ref:`🔗<class_AcceptDialog_signal_confirmed>`
  94. Emitted when the dialog is accepted, i.e. the OK button is pressed.
  95. .. rst-class:: classref-item-separator
  96. ----
  97. .. _class_AcceptDialog_signal_custom_action:
  98. .. rst-class:: classref-signal
  99. **custom_action**\ (\ action\: :ref:`StringName<class_StringName>`\ ) :ref:`🔗<class_AcceptDialog_signal_custom_action>`
  100. Emitted when a custom button with an action is pressed. See :ref:`add_button()<class_AcceptDialog_method_add_button>`.
  101. .. rst-class:: classref-section-separator
  102. ----
  103. .. rst-class:: classref-descriptions-group
  104. Property Descriptions
  105. ---------------------
  106. .. _class_AcceptDialog_property_dialog_autowrap:
  107. .. rst-class:: classref-property
  108. :ref:`bool<class_bool>` **dialog_autowrap** = ``false`` :ref:`🔗<class_AcceptDialog_property_dialog_autowrap>`
  109. .. rst-class:: classref-property-setget
  110. - |void| **set_autowrap**\ (\ value\: :ref:`bool<class_bool>`\ )
  111. - :ref:`bool<class_bool>` **has_autowrap**\ (\ )
  112. Sets autowrapping for the text in the dialog.
  113. .. rst-class:: classref-item-separator
  114. ----
  115. .. _class_AcceptDialog_property_dialog_close_on_escape:
  116. .. rst-class:: classref-property
  117. :ref:`bool<class_bool>` **dialog_close_on_escape** = ``true`` :ref:`🔗<class_AcceptDialog_property_dialog_close_on_escape>`
  118. .. rst-class:: classref-property-setget
  119. - |void| **set_close_on_escape**\ (\ value\: :ref:`bool<class_bool>`\ )
  120. - :ref:`bool<class_bool>` **get_close_on_escape**\ (\ )
  121. If ``true``, the dialog will be hidden when the ``ui_cancel`` action is pressed (by default, this action is bound to :ref:`@GlobalScope.KEY_ESCAPE<class_@GlobalScope_constant_KEY_ESCAPE>`).
  122. .. rst-class:: classref-item-separator
  123. ----
  124. .. _class_AcceptDialog_property_dialog_hide_on_ok:
  125. .. rst-class:: classref-property
  126. :ref:`bool<class_bool>` **dialog_hide_on_ok** = ``true`` :ref:`🔗<class_AcceptDialog_property_dialog_hide_on_ok>`
  127. .. rst-class:: classref-property-setget
  128. - |void| **set_hide_on_ok**\ (\ value\: :ref:`bool<class_bool>`\ )
  129. - :ref:`bool<class_bool>` **get_hide_on_ok**\ (\ )
  130. 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.
  131. \ **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.
  132. .. rst-class:: classref-item-separator
  133. ----
  134. .. _class_AcceptDialog_property_dialog_text:
  135. .. rst-class:: classref-property
  136. :ref:`String<class_String>` **dialog_text** = ``""`` :ref:`🔗<class_AcceptDialog_property_dialog_text>`
  137. .. rst-class:: classref-property-setget
  138. - |void| **set_text**\ (\ value\: :ref:`String<class_String>`\ )
  139. - :ref:`String<class_String>` **get_text**\ (\ )
  140. The text displayed by the dialog.
  141. .. rst-class:: classref-item-separator
  142. ----
  143. .. _class_AcceptDialog_property_ok_button_text:
  144. .. rst-class:: classref-property
  145. :ref:`String<class_String>` **ok_button_text** = ``""`` :ref:`🔗<class_AcceptDialog_property_ok_button_text>`
  146. .. rst-class:: classref-property-setget
  147. - |void| **set_ok_button_text**\ (\ value\: :ref:`String<class_String>`\ )
  148. - :ref:`String<class_String>` **get_ok_button_text**\ (\ )
  149. 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.
  150. .. rst-class:: classref-section-separator
  151. ----
  152. .. rst-class:: classref-descriptions-group
  153. Method Descriptions
  154. -------------------
  155. .. _class_AcceptDialog_method_add_button:
  156. .. rst-class:: classref-method
  157. :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>`
  158. Adds a button with label ``text`` and a custom ``action`` to the dialog and returns the created button.
  159. 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.
  160. If ``true``, ``right`` will place the button to the right of any sibling buttons.
  161. You can use :ref:`remove_button()<class_AcceptDialog_method_remove_button>` method to remove a button created with this method from the dialog.
  162. .. rst-class:: classref-item-separator
  163. ----
  164. .. _class_AcceptDialog_method_add_cancel_button:
  165. .. rst-class:: classref-method
  166. :ref:`Button<class_Button>` **add_cancel_button**\ (\ name\: :ref:`String<class_String>`\ ) :ref:`🔗<class_AcceptDialog_method_add_cancel_button>`
  167. Adds a button with label ``name`` and a cancel action to the dialog and returns the created button.
  168. You can use :ref:`remove_button()<class_AcceptDialog_method_remove_button>` method to remove a button created with this method from the dialog.
  169. .. rst-class:: classref-item-separator
  170. ----
  171. .. _class_AcceptDialog_method_get_label:
  172. .. rst-class:: classref-method
  173. :ref:`Label<class_Label>` **get_label**\ (\ ) :ref:`🔗<class_AcceptDialog_method_get_label>`
  174. Returns the label used for built-in text.
  175. \ **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.
  176. .. rst-class:: classref-item-separator
  177. ----
  178. .. _class_AcceptDialog_method_get_ok_button:
  179. .. rst-class:: classref-method
  180. :ref:`Button<class_Button>` **get_ok_button**\ (\ ) :ref:`🔗<class_AcceptDialog_method_get_ok_button>`
  181. Returns the OK :ref:`Button<class_Button>` instance.
  182. \ **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.
  183. .. rst-class:: classref-item-separator
  184. ----
  185. .. _class_AcceptDialog_method_register_text_enter:
  186. .. rst-class:: classref-method
  187. |void| **register_text_enter**\ (\ line_edit\: :ref:`LineEdit<class_LineEdit>`\ ) :ref:`🔗<class_AcceptDialog_method_register_text_enter>`
  188. Registers a :ref:`LineEdit<class_LineEdit>` in the dialog. When the enter key is pressed, the dialog will be accepted.
  189. .. rst-class:: classref-item-separator
  190. ----
  191. .. _class_AcceptDialog_method_remove_button:
  192. .. rst-class:: classref-method
  193. |void| **remove_button**\ (\ button\: :ref:`Button<class_Button>`\ ) :ref:`🔗<class_AcceptDialog_method_remove_button>`
  194. 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.
  195. .. rst-class:: classref-section-separator
  196. ----
  197. .. rst-class:: classref-descriptions-group
  198. Theme Property Descriptions
  199. ---------------------------
  200. .. _class_AcceptDialog_theme_constant_buttons_min_height:
  201. .. rst-class:: classref-themeproperty
  202. :ref:`int<class_int>` **buttons_min_height** = ``0`` :ref:`🔗<class_AcceptDialog_theme_constant_buttons_min_height>`
  203. 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.
  204. .. rst-class:: classref-item-separator
  205. ----
  206. .. _class_AcceptDialog_theme_constant_buttons_min_width:
  207. .. rst-class:: classref-themeproperty
  208. :ref:`int<class_int>` **buttons_min_width** = ``0`` :ref:`🔗<class_AcceptDialog_theme_constant_buttons_min_width>`
  209. 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.
  210. .. rst-class:: classref-item-separator
  211. ----
  212. .. _class_AcceptDialog_theme_constant_buttons_separation:
  213. .. rst-class:: classref-themeproperty
  214. :ref:`int<class_int>` **buttons_separation** = ``10`` :ref:`🔗<class_AcceptDialog_theme_constant_buttons_separation>`
  215. The size of the vertical space between the dialog's content and the button row.
  216. .. rst-class:: classref-item-separator
  217. ----
  218. .. _class_AcceptDialog_theme_style_panel:
  219. .. rst-class:: classref-themeproperty
  220. :ref:`StyleBox<class_StyleBox>` **panel** :ref:`🔗<class_AcceptDialog_theme_style_panel>`
  221. The panel that fills the background of the window.
  222. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  223. .. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)`
  224. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  225. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  226. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  227. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  228. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  229. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  230. .. |void| replace:: :abbr:`void (No return value.)`