summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2018-12-14 09:04:58 +0100
committerGitHub <noreply@github.com>2018-12-14 09:04:58 +0100
commitfc2038e128d0a38ecc159948d7e41a4a0abefa66 (patch)
tree87b23e7396b05df210583d29ecb9176121fc2464
parent29a527fb9057afd534ea0d6ef6c4b36cc4b3deef (diff)
parentc2fe5c04684105fdfedbc6679f17acec12b3382c (diff)
Merge pull request #24341 from YeldhamDev/buttongroup_expose_get_buttons
Expose ButtonGroup's "get_buttons()" to GDScript
-rw-r--r--doc/classes/ButtonGroup.xml9
-rw-r--r--scene/gui/base_button.cpp11
-rw-r--r--scene/gui/base_button.h1
3 files changed, 20 insertions, 1 deletions
diff --git a/doc/classes/ButtonGroup.xml b/doc/classes/ButtonGroup.xml
index 0f5ea8e6bf..6273c8f83f 100644
--- a/doc/classes/ButtonGroup.xml
+++ b/doc/classes/ButtonGroup.xml
@@ -12,11 +12,18 @@
<demos>
</demos>
<methods>
+ <method name="get_buttons">
+ <return type="Array">
+ </return>
+ <description>
+ Returns an [Array] of [Button]s who have this as their [code]ButtonGroup[/code] (see [member BaseButton.group]).
+ </description>
+ </method>
<method name="get_pressed_button">
<return type="BaseButton">
</return>
<description>
- Return the pressed button.
+ Returns the current pressed button.
</description>
</method>
</methods>
diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp
index 1ac19774f7..dc85c8e641 100644
--- a/scene/gui/base_button.cpp
+++ b/scene/gui/base_button.cpp
@@ -595,6 +595,16 @@ void ButtonGroup::get_buttons(List<BaseButton *> *r_buttons) {
}
}
+Array ButtonGroup::_get_buttons() {
+
+ Array btns;
+ for (Set<BaseButton *>::Element *E = buttons.front(); E; E = E->next()) {
+ btns.push_back(E->get());
+ }
+
+ return btns;
+}
+
BaseButton *ButtonGroup::get_pressed_button() {
for (Set<BaseButton *>::Element *E = buttons.front(); E; E = E->next()) {
@@ -608,6 +618,7 @@ BaseButton *ButtonGroup::get_pressed_button() {
void ButtonGroup::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_pressed_button"), &ButtonGroup::get_pressed_button);
+ ClassDB::bind_method(D_METHOD("get_buttons"), &ButtonGroup::_get_buttons);
}
ButtonGroup::ButtonGroup() {
diff --git a/scene/gui/base_button.h b/scene/gui/base_button.h
index a131e719ad..272c07f68a 100644
--- a/scene/gui/base_button.h
+++ b/scene/gui/base_button.h
@@ -143,6 +143,7 @@ protected:
public:
BaseButton *get_pressed_button();
void get_buttons(List<BaseButton *> *r_buttons);
+ Array _get_buttons();
ButtonGroup();
};