mirror of
https://github.com/godotengine/godot-docs-l10n.git
synced 2025-12-31 09:49:22 +03:00
This reverts commit 57781dc0bc.
The rename, although in line with what we did in the engine, caused problems with RTD we need to fix (or push for a fix) first.
381 lines
20 KiB
ReStructuredText
381 lines
20 KiB
ReStructuredText
:github_url: hide
|
|
|
|
.. _class_AcceptDialog:
|
|
|
|
AcceptDialog
|
|
============
|
|
|
|
**继承:** :ref:`Window<class_Window>` **<** :ref:`Viewport<class_Viewport>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
|
|
|
|
**派生:** :ref:`ConfirmationDialog<class_ConfirmationDialog>`
|
|
|
|
用于用户通知的基本对话框。
|
|
|
|
.. rst-class:: classref-introduction-group
|
|
|
|
描述
|
|
----
|
|
|
|
**AcceptDialog** 的默认用途是允许它只被接受或关闭,结果相同。但是,\ :ref:`confirmed<class_AcceptDialog_signal_confirmed>` 和 :ref:`canceled<class_AcceptDialog_signal_canceled>` 信号允许使两个动作不同,\ :ref:`add_button()<class_AcceptDialog_method_add_button>` 方法允许添加自定义按钮和动作。
|
|
|
|
.. rst-class:: classref-reftable-group
|
|
|
|
属性
|
|
----
|
|
|
|
.. table::
|
|
:widths: auto
|
|
|
|
+-----------------------------+-----------------------------------------------------------------------------------+------------------------------------------------------------------------------+
|
|
| :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:`bool<class_bool>` | keep_title_visible | ``true`` (overrides :ref:`Window<class_Window_property_keep_title_visible>`) |
|
|
+-----------------------------+-----------------------------------------------------------------------------------+------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | maximize_disabled | ``true`` (overrides :ref:`Window<class_Window_property_maximize_disabled>`) |
|
|
+-----------------------------+-----------------------------------------------------------------------------------+------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | minimize_disabled | ``true`` (overrides :ref:`Window<class_Window_property_minimize_disabled>`) |
|
|
+-----------------------------+-----------------------------------------------------------------------------------+------------------------------------------------------------------------------+
|
|
| :ref:`String<class_String>` | :ref:`ok_button_text<class_AcceptDialog_property_ok_button_text>` | ``""`` |
|
|
+-----------------------------+-----------------------------------------------------------------------------------+------------------------------------------------------------------------------+
|
|
| :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
|
|
|
|
方法
|
|
----
|
|
|
|
.. table::
|
|
:widths: auto
|
|
|
|
+-----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :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>` = ""\ ) |
|
|
+-----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Button<class_Button>` | :ref:`add_cancel_button<class_AcceptDialog_method_add_cancel_button>`\ (\ name\: :ref:`String<class_String>`\ ) |
|
|
+-----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :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>`\ (\ line_edit\: :ref:`LineEdit<class_LineEdit>`\ ) |
|
|
+-----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| |void| | :ref:`remove_button<class_AcceptDialog_method_remove_button>`\ (\ button\: :ref:`Button<class_Button>`\ ) |
|
|
+-----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
.. rst-class:: classref-reftable-group
|
|
|
|
主题属性
|
|
--------
|
|
|
|
.. table::
|
|
:widths: auto
|
|
|
|
+---------------------------------+---------------------------------------------------------------------------------+--------+
|
|
| :ref:`int<class_int>` | :ref:`buttons_min_height<class_AcceptDialog_theme_constant_buttons_min_height>` | ``0`` |
|
|
+---------------------------------+---------------------------------------------------------------------------------+--------+
|
|
| :ref:`int<class_int>` | :ref:`buttons_min_width<class_AcceptDialog_theme_constant_buttons_min_width>` | ``0`` |
|
|
+---------------------------------+---------------------------------------------------------------------------------+--------+
|
|
| :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
|
|
|
|
信号
|
|
----
|
|
|
|
.. _class_AcceptDialog_signal_canceled:
|
|
|
|
.. rst-class:: classref-signal
|
|
|
|
**canceled**\ (\ ) :ref:`🔗<class_AcceptDialog_signal_canceled>`
|
|
|
|
当对话框关闭或按下 :ref:`add_cancel_button()<class_AcceptDialog_method_add_cancel_button>` 创建的按钮时发出。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_AcceptDialog_signal_confirmed:
|
|
|
|
.. rst-class:: classref-signal
|
|
|
|
**confirmed**\ (\ ) :ref:`🔗<class_AcceptDialog_signal_confirmed>`
|
|
|
|
接受对话框时,即按下确定按钮时发出。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_AcceptDialog_signal_custom_action:
|
|
|
|
.. rst-class:: classref-signal
|
|
|
|
**custom_action**\ (\ action\: :ref:`StringName<class_StringName>`\ ) :ref:`🔗<class_AcceptDialog_signal_custom_action>`
|
|
|
|
按下带有动作的自定义按钮时发出。参见 :ref:`add_button()<class_AcceptDialog_method_add_button>`\ 。
|
|
|
|
.. rst-class:: classref-section-separator
|
|
|
|
----
|
|
|
|
.. rst-class:: classref-descriptions-group
|
|
|
|
属性说明
|
|
--------
|
|
|
|
.. _class_AcceptDialog_property_dialog_autowrap:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`bool<class_bool>` **dialog_autowrap** = ``false`` :ref:`🔗<class_AcceptDialog_property_dialog_autowrap>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_autowrap**\ (\ value\: :ref:`bool<class_bool>`\ )
|
|
- :ref:`bool<class_bool>` **has_autowrap**\ (\ )
|
|
|
|
为对话框中的文本设置自动换行。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_AcceptDialog_property_dialog_close_on_escape:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`bool<class_bool>` **dialog_close_on_escape** = ``true`` :ref:`🔗<class_AcceptDialog_property_dialog_close_on_escape>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_close_on_escape**\ (\ value\: :ref:`bool<class_bool>`\ )
|
|
- :ref:`bool<class_bool>` **get_close_on_escape**\ (\ )
|
|
|
|
如果为 ``true``\ ,则按下 ``ui_cancel`` 动作时会隐藏对话框(该动作默认绑定至 :ref:`@GlobalScope.KEY_ESCAPE<class_@GlobalScope_constant_KEY_ESCAPE>`\ )。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_AcceptDialog_property_dialog_hide_on_ok:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`bool<class_bool>` **dialog_hide_on_ok** = ``true`` :ref:`🔗<class_AcceptDialog_property_dialog_hide_on_ok>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_hide_on_ok**\ (\ value\: :ref:`bool<class_bool>`\ )
|
|
- :ref:`bool<class_bool>` **get_hide_on_ok**\ (\ )
|
|
|
|
如果为 ``true``\ ,按下确定按钮时对话框将隐藏。如果要在收到 :ref:`confirmed<class_AcceptDialog_signal_confirmed>` 信号时执行类似输入验证的操作,则可以将其设置为 ``false``\ ,然后在自己的逻辑中处理对话框的隐藏。
|
|
|
|
\ **注意:**\ 从此类派生的某些节点可以具有不同的默认值,并且可能有自己的内置逻辑会覆盖此设置。例如 :ref:`FileDialog<class_FileDialog>` 默认其为 ``false``\ ,并在按下确定时实现了自己的输入验证代码,如果输入有效,最终将隐藏对话框。因此,不能在 :ref:`FileDialog<class_FileDialog>` 中使用此属性来禁止在按确定时隐藏对话框。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_AcceptDialog_property_dialog_text:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`String<class_String>` **dialog_text** = ``""`` :ref:`🔗<class_AcceptDialog_property_dialog_text>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_text**\ (\ value\: :ref:`String<class_String>`\ )
|
|
- :ref:`String<class_String>` **get_text**\ (\ )
|
|
|
|
对话框显示的文本。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_AcceptDialog_property_ok_button_text:
|
|
|
|
.. rst-class:: classref-property
|
|
|
|
:ref:`String<class_String>` **ok_button_text** = ``""`` :ref:`🔗<class_AcceptDialog_property_ok_button_text>`
|
|
|
|
.. rst-class:: classref-property-setget
|
|
|
|
- |void| **set_ok_button_text**\ (\ value\: :ref:`String<class_String>`\ )
|
|
- :ref:`String<class_String>` **get_ok_button_text**\ (\ )
|
|
|
|
确定按钮显示的文本(见 :ref:`get_ok_button()<class_AcceptDialog_method_get_ok_button>`\ )。留空时使用默认文本。
|
|
|
|
.. rst-class:: classref-section-separator
|
|
|
|
----
|
|
|
|
.. rst-class:: classref-descriptions-group
|
|
|
|
方法说明
|
|
--------
|
|
|
|
.. _class_AcceptDialog_method_add_button:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
: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>`
|
|
|
|
将带有标签 ``text`` 和自定义 ``action`` 的按钮添加到对话框,并返回该创建的按钮。
|
|
|
|
如果 ``action`` 不为空,按下按钮将发出具有指定动作字符串的 :ref:`custom_action<class_AcceptDialog_signal_custom_action>` 信号。
|
|
|
|
如果 ``right`` 为 ``true``\ ,按钮会被放置在所有同级按钮的右侧。
|
|
|
|
可以使用 :ref:`remove_button()<class_AcceptDialog_method_remove_button>` 方法从对话框中移除使用该方法创建的按钮。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_AcceptDialog_method_add_cancel_button:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`Button<class_Button>` **add_cancel_button**\ (\ name\: :ref:`String<class_String>`\ ) :ref:`🔗<class_AcceptDialog_method_add_cancel_button>`
|
|
|
|
在对话框中添加一个带有标签 ``name`` 和取消动作的按钮,并返回创建的按钮。
|
|
|
|
你可以使用 :ref:`remove_button()<class_AcceptDialog_method_remove_button>` 方法从对话框中删除用此方法创建的按钮。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_AcceptDialog_method_get_label:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`Label<class_Label>` **get_label**\ (\ ) :ref:`🔗<class_AcceptDialog_method_get_label>`
|
|
|
|
返回内置文本所使用的标签。
|
|
|
|
\ **警告:**\ 这是个必要的内部节点,移除并释放它有可能造成崩溃。如果你希望隐藏它或它的任意一个子节点,请使用它们的 :ref:`CanvasItem.visible<class_CanvasItem_property_visible>` 属性。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_AcceptDialog_method_get_ok_button:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
:ref:`Button<class_Button>` **get_ok_button**\ (\ ) :ref:`🔗<class_AcceptDialog_method_get_ok_button>`
|
|
|
|
返回确定按钮 :ref:`Button<class_Button>` 实例。
|
|
|
|
\ **警告:**\ 这是个必要的内部节点,移除并释放它有可能造成崩溃。如果你希望隐藏它或它的任意一个子节点,请使用它们的 :ref:`CanvasItem.visible<class_CanvasItem_property_visible>` 属性。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_AcceptDialog_method_register_text_enter:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
|void| **register_text_enter**\ (\ line_edit\: :ref:`LineEdit<class_LineEdit>`\ ) :ref:`🔗<class_AcceptDialog_method_register_text_enter>`
|
|
|
|
在对话框中注册 :ref:`LineEdit<class_LineEdit>`\ 。当按下回车键时,对话框将被接受。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_AcceptDialog_method_remove_button:
|
|
|
|
.. rst-class:: classref-method
|
|
|
|
|void| **remove_button**\ (\ button\: :ref:`Button<class_Button>`\ ) :ref:`🔗<class_AcceptDialog_method_remove_button>`
|
|
|
|
从对话框中移除 ``button``\ 。但不释放该 ``button`` 对象。\ ``button`` 必须是用 :ref:`add_button()<class_AcceptDialog_method_add_button>` 或 :ref:`add_cancel_button()<class_AcceptDialog_method_add_cancel_button>` 方法添加的 :ref:`Button<class_Button>`\ 。移除后,按下该 ``button`` 将不再发出该对话框的 :ref:`custom_action<class_AcceptDialog_signal_custom_action>` 或 :ref:`canceled<class_AcceptDialog_signal_canceled>` 信号。
|
|
|
|
.. rst-class:: classref-section-separator
|
|
|
|
----
|
|
|
|
.. rst-class:: classref-descriptions-group
|
|
|
|
主题属性说明
|
|
------------
|
|
|
|
.. _class_AcceptDialog_theme_constant_buttons_min_height:
|
|
|
|
.. rst-class:: classref-themeproperty
|
|
|
|
:ref:`int<class_int>` **buttons_min_height** = ``0`` :ref:`🔗<class_AcceptDialog_theme_constant_buttons_min_height>`
|
|
|
|
底部按钮(如确定、取消)的最小高度,单位为像素。可以让文本较短的按钮更便于点击/点按。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_AcceptDialog_theme_constant_buttons_min_width:
|
|
|
|
.. rst-class:: classref-themeproperty
|
|
|
|
:ref:`int<class_int>` **buttons_min_width** = ``0`` :ref:`🔗<class_AcceptDialog_theme_constant_buttons_min_width>`
|
|
|
|
底部按钮(如确定、取消)的最小宽度,单位为像素。可以让文本较短的按钮更便于点击/点按。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_AcceptDialog_theme_constant_buttons_separation:
|
|
|
|
.. rst-class:: classref-themeproperty
|
|
|
|
:ref:`int<class_int>` **buttons_separation** = ``10`` :ref:`🔗<class_AcceptDialog_theme_constant_buttons_separation>`
|
|
|
|
对话框内容和按钮行之间的垂直空间的大小。
|
|
|
|
.. rst-class:: classref-item-separator
|
|
|
|
----
|
|
|
|
.. _class_AcceptDialog_theme_style_panel:
|
|
|
|
.. rst-class:: classref-themeproperty
|
|
|
|
:ref:`StyleBox<class_StyleBox>` **panel** :ref:`🔗<class_AcceptDialog_theme_style_panel>`
|
|
|
|
填充窗口背景的面板。
|
|
|
|
.. |virtual| replace:: :abbr:`virtual (本方法通常需要用户覆盖才能生效。)`
|
|
.. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)`
|
|
.. |const| replace:: :abbr:`const (本方法无副作用,不会修改该实例的任何成员变量。)`
|
|
.. |vararg| replace:: :abbr:`vararg (本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。)`
|
|
.. |constructor| replace:: :abbr:`constructor (本方法用于构造某个类型。)`
|
|
.. |static| replace:: :abbr:`static (调用本方法无需实例,可直接使用类名进行调用。)`
|
|
.. |operator| replace:: :abbr:`operator (本方法描述的是使用本类型作为左操作数的有效运算符。)`
|
|
.. |bitfield| replace:: :abbr:`BitField (这个值是由下列位标志构成位掩码的整数。)`
|
|
.. |void| replace:: :abbr:`void (无返回值。)`
|