Merge pull request #24341 from YeldhamDev/buttongroup_expose_get_buttons
Expose ButtonGroup's "get_buttons()" to GDScript
This commit is contained in:
commit
fc2038e128
3 changed files with 20 additions and 1 deletions
|
@ -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>
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -143,6 +143,7 @@ protected:
|
|||
public:
|
||||
BaseButton *get_pressed_button();
|
||||
void get_buttons(List<BaseButton *> *r_buttons);
|
||||
Array _get_buttons();
|
||||
ButtonGroup();
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue