summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-05-06 23:20:33 +0200
committerGitHub <noreply@github.com>2021-05-06 23:20:33 +0200
commit89e6f6ca2eecb30968af686d53a12f41cd265422 (patch)
treef427e096bed6f01a121772189a7a2c2e4b89b34c /scene/gui
parenta33a8f1e2919aa6c5793c52c74ca7fbf71a3aeba (diff)
parent323f1769157cd9e30c504fa6f54e8ba0889cfac3 (diff)
Merge pull request #48500 from groud/add_buttongroup_pressed_signal
Adds a pressed signal to ButtonGroup
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/base_button.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp
index 826fd0189b..ac067aa001 100644
--- a/scene/gui/base_button.cpp
+++ b/scene/gui/base_button.cpp
@@ -155,6 +155,9 @@ void BaseButton::on_action_event(Ref<InputEvent> p_event) {
}
status.pressed = !status.pressed;
_unpress_group();
+ if (button_group.is_valid()) {
+ button_group->emit_signal("pressed", this);
+ }
_toggled(status.pressed);
_pressed();
}
@@ -218,6 +221,9 @@ void BaseButton::set_pressed(bool p_pressed) {
if (p_pressed) {
_unpress_group();
+ if (button_group.is_valid()) {
+ button_group->emit_signal("pressed", this);
+ }
}
_toggled(status.pressed);
@@ -487,6 +493,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);
+ ADD_SIGNAL(MethodInfo("pressed", PropertyInfo(Variant::OBJECT, "button")));
}
ButtonGroup::ButtonGroup() {