AcceptDialog

继承: Window < Viewport < Item < Object

派生: ConfirmationDialog

用于用户提示的基本对话框。

描述

AcceptDialog的默认使用是只允许它被接受或关闭,结果相同。但是,confirmedcanceled信号允许使两个操作不同,add_button()方法允许添加自定义按钮和操作。

属性

bool

dialog_autowrap

false

bool

dialog_close_on_escape

true

bool

dialog_hide_on_ok

true

String

dialog_text

""

bool

exclusive

true (overrides Window)

bool

keep_title_visible

true (overrides Window)

String

ok_button_text

"OK"

String

title

"Alert!" (overrides Window)

bool

transient

true (overrides Window)

bool

visible

false (overrides Window)

bool

wrap_controls

true (overrides Window)

方法

Button

add_button(text: String, right: bool = false, action: String = "")

Button

add_cancel_button(name: String)

Label

get_label()

Button

get_ok_button()

void

register_text_enter(line_edit: LineEdit)

void

remove_button(button: Button)

主题属性


信号

canceled() 🔗

关闭对话框或按下使用add_cancel_button()创建的按钮时发出。


confirmed() 🔗

接受对话框时发出,即按下确定按钮。


custom_action(action: StringName) 🔗

按下自定义按钮时发出。参见add_button()


属性说明

bool dialog_autowrap = false 🔗

  • void set_autowrap(value: bool)

  • bool has_autowrap()

为对话框中的文本设置自动包装。


bool dialog_close_on_escape = true 🔗

  • void set_close_on_escape(value: bool)

  • bool get_close_on_escape()

如果true,则当按下转义键(@GlobalScope.KEY_ESCAPE)时,对话框将被隐藏。


bool dialog_hide_on_ok = true 🔗

  • void set_hide_on_ok(value: bool)

  • bool get_hide_on_ok()

如果true,则在按下OK按钮时隐藏对话框。如果您想在接收到confirmed信号时进行输入验证,可以将其设置为false,并处理在您自己的逻辑中隐藏对话框。

注意:从该类派生的一些节点可能有不同的默认值,并且可能有它们自己的内置逻辑覆盖此设置。例如FileDialog默认为false,并且有自己的输入验证代码,当您按OK时调用该代码,如果输入有效,该代码最终会隐藏对话框。因此,在FileDialog中不能使用此属性来禁用按OK时隐藏对话框。


String dialog_text = "" 🔗

对话框显示的文本。


String ok_button_text = "OK" 🔗

  • void set_ok_button_text(value: String)

  • String get_ok_button_text()

OK按钮显示的文本(参见get_ok_button())。


方法说明

Button add_button(text: String, right: bool = false, action: String = "") 🔗

将带有标签text和自定义action的按钮添加到对话框并返回创建的按钮。按下时,action将传递给custom_action信号。

如果trueright将把按钮放在任何兄弟按钮的右侧。

您可以使用remove_button()方法从对话框中删除使用此方法创建的按钮。


Button add_cancel_button(name: String) 🔗

将带有标签name和取消操作的按钮添加到对话框并返回创建的按钮。

您可以使用remove_button()方法从对话框中删除使用此方法创建的按钮。


Label get_label() 🔗

返回用于内置文本的标签。

警告:这是一个必需的内部节点,删除和释放它可能会导致崩溃。如果您希望隐藏它或它的任何子节点,请使用它们的CanvasItem.visible属性。


Button get_ok_button() 🔗

返回OKButton实例。

警告:这是一个必需的内部节点,删除和释放它可能会导致崩溃。如果您希望隐藏它或它的任何子节点,请使用它们的CanvasItem.visible属性。


void register_text_enter(line_edit: LineEdit) 🔗

在对话框中注册LineEdit。当按下回车键时,对话框将被接受。


void remove_button(button: Button) 🔗

从对话框中移除button。不释放buttonbutton必须是添加了add_button()add_cancel_button()方法的Button。移除后,按下button将不再发出此对话框的custom_actioncanceled信号。


主题属性说明

int buttons_min_height = 0 🔗

底部行中每个按钮的最小高度(例如确定/取消),以像素为单位。这可以增加以使带有短文本的按钮更容易单击/点击。


int buttons_min_width = 0 🔗

底部行中每个按钮的最小宽度(例如确定/取消),以像素为单位。这可以增加以使带有短文本的按钮更容易单击/点击。


int buttons_separation = 10 🔗

对话框内容和按钮行之间的垂直空间大小。


StyleBox panel 🔗

填充窗口背景的面板。