From 2cedf7173a104a1b17af38b9c663a339c5fa664d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Wed, 12 Jun 2019 16:31:01 +0200 Subject: BaseButton: Make shortcuts call virtual methods When buttons are not in Toggle Mode, shortcuts used to only trigger the `pressed` signal, without calling the `_pressed` virtual method, contrarily to what happens when you click the button. For Toggle Mode buttons, it did call the `_toggled` virtual method together with emitting the `toggled` signal *twice*. This commit harmonizes it all and makes shortcuts behave the same as mouse clicks or `ui_accept`, for both toggle and non-toggle modes. Fixes #29604. --- scene/gui/base_button.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'scene/gui') diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp index 5ef2557383..fadf5e432c 100644 --- a/scene/gui/base_button.cpp +++ b/scene/gui/base_button.cpp @@ -216,9 +216,7 @@ void BaseButton::set_pressed(bool p_pressed) { if (p_pressed) { _unpress_group(); } - if (toggle_mode) { - _toggled(status.pressed); - } + _toggled(status.pressed); update(); } @@ -337,9 +335,6 @@ bool BaseButton::is_keep_pressed_outside() const { void BaseButton::set_shortcut(const Ref &p_shortcut) { - if (shortcut.is_null() == p_shortcut.is_null()) - return; - shortcut = p_shortcut; set_process_unhandled_input(shortcut.is_valid()); } @@ -356,11 +351,10 @@ void BaseButton::_unhandled_input(Ref p_event) { return; //ignore because of modal window if (is_toggle_mode()) { - set_pressed(!is_pressed()); - emit_signal("toggled", is_pressed()); + set_pressed(!is_pressed()); // Also calls _toggled() internally. } - emit_signal("pressed"); + _pressed(); } } -- cgit v1.2.3