mirror of
https://github.com/godotengine/godot-docs-l10n.git
synced 2025-12-31 09:49:22 +03:00
383 lines
20 KiB
ReStructuredText
383 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
|
|
|
|
說明
|
|
----
|
|
|
|
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.
|
|
|
|
\ **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>`.
|
|
|
|
.. 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>`
|
|
|
|
當對話框被接受(即按下 OK 按鈕)時觸發。
|
|
|
|
.. 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>`
|
|
|
|
Emitted when a custom button with an action is pressed. See :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**\ (\ )
|
|
|
|
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).
|
|
|
|
.. 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``\ ,按下 OK 按鈕時對話框會隱藏。若你希望在收到 :ref:`confirmed<class_AcceptDialog_signal_confirmed>` 訊號時執行輸入驗證等邏輯,可將此屬性設為 ``false``\ ,並由你自己的程式邏輯來隱藏對話框。
|
|
|
|
\ **注意:**\ 某些繼承自此類別的節點可能預設為不同值,且有自己的內建邏輯會覆蓋此設定。例如 :ref:`FileDialog<class_FileDialog>` 預設為 ``false``\ ,並在按下 OK 時會執行輸入驗證,若輸入有效則最終自動隱藏對話框。因此,此屬性無法用於 :ref:`FileDialog<class_FileDialog>` 來禁止按 OK 時隱藏對話框。
|
|
|
|
.. 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**\ (\ )
|
|
|
|
OK 按鈕顯示的文字(參見 :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>`
|
|
|
|
Adds a button with label ``text`` and a custom ``action`` to the dialog and returns the created button.
|
|
|
|
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.
|
|
|
|
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
|
|
|
|
----
|
|
|
|
.. _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>`
|
|
|
|
回傳 OK :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>`\ 。當按下 Enter 鍵時,對話框將被接受。
|
|
|
|
.. 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>`
|
|
|
|
底部按鈕列(如 OK/取消)的每個按鈕最小高度(像素)。可增加此值,使短文字的按鈕更易於點擊或觸控。
|
|
|
|
.. 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>`
|
|
|
|
底部按鈕列(如 OK/取消)的每個按鈕最小寬度(像素)。可增加此值,使短文字的按鈕更易於點擊或觸控。
|
|
|
|
.. 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 (無回傳值。)`
|