Skip to content

Latest commit

 

History

History
347 lines (205 loc) · 16.9 KB

class_acceptdialog.rst

File metadata and controls

347 lines (205 loc) · 16.9 KB
github_url:hide

AcceptDialog

Inherits: :ref:`Window<class_Window>` < :ref:`Viewport<class_Viewport>` < :ref:`Node<class_Node>` < :ref:`Object<class_Object>`

Inherited By: :ref:`ConfirmationDialog<class_ConfirmationDialog>`

A base dialog used for user notification.

.. rst-class:: classref-introduction-group

Description

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.

.. rst-class:: classref-reftable-group

Properties

:ref:`bool<class_bool>` :ref:`dialog_autowrap<class_AcceptDialog_property_dialog_autowrap>` false
:ref:`bool<class_bool>` :ref:`dialog_close_on_escape<class_AcceptDialog_property_dialog_close_on_escape>` true
:ref:`bool<class_bool>` :ref:`dialog_hide_on_ok<class_AcceptDialog_property_dialog_hide_on_ok>` true
:ref:`String<class_String>` :ref:`dialog_text<class_AcceptDialog_property_dialog_text>` ""
:ref:`bool<class_bool>` exclusive true (overrides :ref:`Window<class_Window_property_exclusive>`)
:ref:`String<class_String>` :ref:`ok_button_text<class_AcceptDialog_property_ok_button_text>` "OK"
:ref:`String<class_String>` title "Alert!" (overrides :ref:`Window<class_Window_property_title>`)
:ref:`bool<class_bool>` transient true (overrides :ref:`Window<class_Window_property_transient>`)
:ref:`bool<class_bool>` visible false (overrides :ref:`Window<class_Window_property_visible>`)
:ref:`bool<class_bool>` wrap_controls true (overrides :ref:`Window<class_Window_property_wrap_controls>`)
.. rst-class:: classref-reftable-group

Methods

: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="" )
:ref:`Button<class_Button>` :ref:`add_cancel_button<class_AcceptDialog_method_add_cancel_button>` ( :ref:`String<class_String>` name )
:ref:`Label<class_Label>` :ref:`get_label<class_AcceptDialog_method_get_label>` ( )
:ref:`Button<class_Button>` :ref:`get_ok_button<class_AcceptDialog_method_get_ok_button>` ( )
void :ref:`register_text_enter<class_AcceptDialog_method_register_text_enter>` ( :ref:`Control<class_Control>` line_edit )
void :ref:`remove_button<class_AcceptDialog_method_remove_button>` ( :ref:`Control<class_Control>` button )
.. rst-class:: classref-reftable-group

Theme Properties

:ref:`int<class_int>` :ref:`buttons_separation<class_AcceptDialog_theme_constant_buttons_separation>` 10
:ref:`StyleBox<class_StyleBox>` :ref:`panel<class_AcceptDialog_theme_style_panel>`  
.. rst-class:: classref-section-separator


.. rst-class:: classref-descriptions-group

Signals

.. rst-class:: classref-signal

canceled ( )

Emitted when the dialog is closed or the button created with :ref:`add_cancel_button<class_AcceptDialog_method_add_cancel_button>` is pressed.

.. rst-class:: classref-item-separator


.. rst-class:: classref-signal

confirmed ( )

Emitted when the dialog is accepted, i.e. the OK button is pressed.

.. rst-class:: classref-item-separator


.. rst-class:: classref-signal

custom_action ( :ref:`StringName<class_StringName>` action )

Emitted when a custom button is pressed. See :ref:`add_button<class_AcceptDialog_method_add_button>`.

.. rst-class:: classref-section-separator


.. rst-class:: classref-descriptions-group

Property Descriptions

.. rst-class:: classref-property

:ref:`bool<class_bool>` dialog_autowrap = false

.. rst-class:: classref-property-setget

Sets autowrapping for the text in the dialog.

.. rst-class:: classref-item-separator


.. rst-class:: classref-property

:ref:`bool<class_bool>` dialog_close_on_escape = true

.. rst-class:: classref-property-setget

If true, the dialog will be hidden when the escape key (:ref:`@GlobalScope.KEY_ESCAPE<class_@GlobalScope_constant_KEY_ESCAPE>`) is pressed.

.. rst-class:: classref-item-separator


.. rst-class:: classref-property

:ref:`bool<class_bool>` dialog_hide_on_ok = true

.. rst-class:: classref-property-setget

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.

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.

.. rst-class:: classref-item-separator


.. rst-class:: classref-property

:ref:`String<class_String>` dialog_text = ""

.. rst-class:: classref-property-setget

The text displayed by the dialog.

.. rst-class:: classref-item-separator


.. rst-class:: classref-property

:ref:`String<class_String>` ok_button_text = "OK"

.. rst-class:: classref-property-setget

The text displayed by the OK button (see :ref:`get_ok_button<class_AcceptDialog_method_get_ok_button>`).

.. rst-class:: classref-section-separator


.. rst-class:: classref-descriptions-group

Method Descriptions

.. rst-class:: classref-method

:ref:`Button<class_Button>` add_button ( :ref:`String<class_String>` text, :ref:`bool<class_bool>` right=false, :ref:`String<class_String>` action="" )

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.

If true, right will place the button to the right of any sibling buttons.

You can use :ref:`remove_button<class_AcceptDialog_method_remove_button>` method to remove a button created with this method from the dialog.

.. rst-class:: classref-item-separator


.. rst-class:: classref-method

:ref:`Button<class_Button>` add_cancel_button ( :ref:`String<class_String>` name )

Adds a button with label name and a cancel action to the dialog and returns the created button.

You can use :ref:`remove_button<class_AcceptDialog_method_remove_button>` method to remove a button created with this method from the dialog.

.. rst-class:: classref-item-separator


.. rst-class:: classref-method

:ref:`Label<class_Label>` get_label ( )

Returns the label used for built-in text.

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.

.. rst-class:: classref-item-separator


.. rst-class:: classref-method

:ref:`Button<class_Button>` get_ok_button ( )

Returns the OK :ref:`Button<class_Button>` instance.

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.

.. rst-class:: classref-item-separator


.. rst-class:: classref-method

void register_text_enter ( :ref:`Control<class_Control>` line_edit )

Registers a :ref:`LineEdit<class_LineEdit>` in the dialog. When the enter key is pressed, the dialog will be accepted.

.. rst-class:: classref-item-separator


.. rst-class:: classref-method

void remove_button ( :ref:`Control<class_Control>` button )

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.

.. rst-class:: classref-section-separator


.. rst-class:: classref-descriptions-group

Theme Property Descriptions

.. rst-class:: classref-themeproperty

:ref:`int<class_int>` buttons_separation = 10

The size of the vertical space between the dialog's content and the button row.

.. rst-class:: classref-item-separator


.. rst-class:: classref-themeproperty

:ref:`StyleBox<class_StyleBox>` panel

The panel that fills the background of the window.