From 714e6a595d69802baa796190d0e682d0679a0f43 Mon Sep 17 00:00:00 2001 From: kleonc <9283098+kleonc@users.noreply.github.com> Date: Tue, 6 Jul 2021 17:51:56 +0200 Subject: [PATCH] Add AcceptDialog::remove_button method --- doc/classes/AcceptDialog.xml | 11 +++++++++++ scene/gui/dialogs.cpp | 23 +++++++++++++++++++++++ scene/gui/dialogs.h | 1 + 3 files changed, 35 insertions(+) diff --git a/doc/classes/AcceptDialog.xml b/doc/classes/AcceptDialog.xml index f644606040..fd1e2ba104 100644 --- a/doc/classes/AcceptDialog.xml +++ b/doc/classes/AcceptDialog.xml @@ -21,6 +21,7 @@ Adds a button with label [code]text[/code] and a custom [code]action[/code] to the dialog and returns the created button. [code]action[/code] will be passed to the [signal custom_action] signal when pressed. If [code]true[/code], [code]right[/code] will place the button to the right of any sibling buttons. + You can use [method remove_button] method to remove a button created with this method from the dialog. @@ -30,6 +31,7 @@ Adds a button with label [code]name[/code] and a cancel action to the dialog and returns the created button. + You can use [method remove_button] method to remove a button created with this method from the dialog. @@ -55,6 +57,15 @@ Registers a [LineEdit] in the dialog. When the enter key is pressed, the dialog will be accepted. + + + + + + + Removes the [code]button[/code] from the dialog. Does NOT free the [code]button[/code]. The [code]button[/code] must be a [Button] added with [method add_button] or [method add_cancel_button] method. After removal, pressing the [code]button[/code] will no longer emit this dialog's [signal custom_action] or [signal cancelled] signals. + + diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp index f63ae7569f..dceab00607 100644 --- a/scene/gui/dialogs.cpp +++ b/scene/gui/dialogs.cpp @@ -263,6 +263,28 @@ Button *AcceptDialog::add_cancel_button(const String &p_cancel) { return b; } +void AcceptDialog::remove_button(Control *p_button) { + Button *button = Object::cast_to