Adds a pressed signal to ButtonGroup
This commit is contained in:
parent
d81ea631d9
commit
323f176915
|
@ -28,6 +28,15 @@
|
||||||
<members>
|
<members>
|
||||||
<member name="resource_local_to_scene" type="bool" setter="set_local_to_scene" getter="is_local_to_scene" override="true" default="true" />
|
<member name="resource_local_to_scene" type="bool" setter="set_local_to_scene" getter="is_local_to_scene" override="true" default="true" />
|
||||||
</members>
|
</members>
|
||||||
|
<signals>
|
||||||
|
<signal name="pressed">
|
||||||
|
<argument index="0" name="button" type="Object">
|
||||||
|
</argument>
|
||||||
|
<description>
|
||||||
|
Emitted when one of the buttons of the group is pressed.
|
||||||
|
</description>
|
||||||
|
</signal>
|
||||||
|
</signals>
|
||||||
<constants>
|
<constants>
|
||||||
</constants>
|
</constants>
|
||||||
</class>
|
</class>
|
||||||
|
|
|
@ -155,6 +155,9 @@ void BaseButton::on_action_event(Ref<InputEvent> p_event) {
|
||||||
}
|
}
|
||||||
status.pressed = !status.pressed;
|
status.pressed = !status.pressed;
|
||||||
_unpress_group();
|
_unpress_group();
|
||||||
|
if (button_group.is_valid()) {
|
||||||
|
button_group->emit_signal("pressed", this);
|
||||||
|
}
|
||||||
_toggled(status.pressed);
|
_toggled(status.pressed);
|
||||||
_pressed();
|
_pressed();
|
||||||
}
|
}
|
||||||
|
@ -218,6 +221,9 @@ void BaseButton::set_pressed(bool p_pressed) {
|
||||||
|
|
||||||
if (p_pressed) {
|
if (p_pressed) {
|
||||||
_unpress_group();
|
_unpress_group();
|
||||||
|
if (button_group.is_valid()) {
|
||||||
|
button_group->emit_signal("pressed", this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_toggled(status.pressed);
|
_toggled(status.pressed);
|
||||||
|
|
||||||
|
@ -487,6 +493,7 @@ BaseButton *ButtonGroup::get_pressed_button() {
|
||||||
void ButtonGroup::_bind_methods() {
|
void ButtonGroup::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("get_pressed_button"), &ButtonGroup::get_pressed_button);
|
ClassDB::bind_method(D_METHOD("get_pressed_button"), &ButtonGroup::get_pressed_button);
|
||||||
ClassDB::bind_method(D_METHOD("get_buttons"), &ButtonGroup::_get_buttons);
|
ClassDB::bind_method(D_METHOD("get_buttons"), &ButtonGroup::_get_buttons);
|
||||||
|
ADD_SIGNAL(MethodInfo("pressed", PropertyInfo(Variant::OBJECT, "button")));
|
||||||
}
|
}
|
||||||
|
|
||||||
ButtonGroup::ButtonGroup() {
|
ButtonGroup::ButtonGroup() {
|
||||||
|
|
Loading…
Reference in New Issue