class_acceptdialog.rst 17 KB

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