Table of Contents

Class AcceptDialog

Namespace
Godot
Assembly
GodotSharp.dll

The default use of AcceptDialog is to allow it to only be accepted or closed, with the same result. However, the Confirmed and Canceled signals allow to make the two actions different, and the AddButton(string, bool, string) method allows to add custom buttons and actions.

public class AcceptDialog : Window, IDisposable
Inheritance
AcceptDialog
Implements
Derived
Inherited Members

Constructors

AcceptDialog()

public AcceptDialog()

Properties

DialogAutowrap

Sets autowrapping for the text in the dialog.

public bool DialogAutowrap { get; set; }

Property Value

bool

DialogCloseOnEscape

If true, the dialog will be hidden when the escape key (Escape) is pressed.

public bool DialogCloseOnEscape { get; set; }

Property Value

bool

DialogHideOnOk

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 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 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 FileDialog to disable hiding the dialog when pressing OK.

public bool DialogHideOnOk { get; set; }

Property Value

bool

DialogText

The text displayed by the dialog.

public string DialogText { get; set; }

Property Value

string

OkButtonText

The text displayed by the OK button (see GetOkButton()).

public string OkButtonText { get; set; }

Property Value

string

Methods

AddButton(string, bool, string)

Adds a button with label text and a custom action to the dialog and returns the created button. action will be passed to the CustomAction signal when pressed.

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

You can use RemoveButton(Control) method to remove a button created with this method from the dialog.

public Button AddButton(string text, bool right = false, string action = "")

Parameters

text string
right bool
action string

Returns

Button

AddCancelButton(string)

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

You can use RemoveButton(Control) method to remove a button created with this method from the dialog.

public Button AddCancelButton(string name)

Parameters

name string

Returns

Button

GetLabel()

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 Visible property.

public Label GetLabel()

Returns

Label

GetOkButton()

Returns the OK 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 Visible property.

public Button GetOkButton()

Returns

Button

HasGodotClassMethod(in godot_string_name)

Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.

protected override bool HasGodotClassMethod(in godot_string_name method)

Parameters

method godot_string_name

Name of the method to check for.

Returns

bool

HasGodotClassSignal(in godot_string_name)

Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.

protected override bool HasGodotClassSignal(in godot_string_name signal)

Parameters

signal godot_string_name

Name of the signal to check for.

Returns

bool

InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)

Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.

protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)

Parameters

method godot_string_name

Name of the method to invoke.

args NativeVariantPtrArgs

Arguments to use with the invoked method.

ret godot_variant

Value returned by the invoked method.

Returns

bool

RegisterTextEnter(Control)

Registers a LineEdit in the dialog. When the enter key is pressed, the dialog will be accepted.

public void RegisterTextEnter(Control lineEdit)

Parameters

lineEdit Control

RemoveButton(Control)

Removes the button from the dialog. Does NOT free the button. The button must be a Button added with AddButton(string, bool, string) or AddCancelButton(string) method. After removal, pressing the button will no longer emit this dialog's CustomAction or Canceled signals.

public void RemoveButton(Control button)

Parameters

button Control

Events

Canceled

Emitted when the dialog is closed or the button created with AddCancelButton(string) is pressed.

public event Action Canceled

Event Type

Action

Confirmed

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

public event Action Confirmed

Event Type

Action

CustomAction

Emitted when a custom button is pressed. See AddButton(string, bool, string).

public event AcceptDialog.CustomActionEventHandler CustomAction

Event Type

AcceptDialog.CustomActionEventHandler