From 5fad8917590c9e9202cdcf67fdce3d9ee97be606 Mon Sep 17 00:00:00 2001 From: Mark Wilson <23439518+wlsnmrk@users.noreply.github.com> Date: Tue, 7 Jan 2025 16:15:38 -0500 Subject: [PATCH] Fix menus and dropdowns requiring two clicks Fixes some editor menus and option buttons requiring two clicks to open by checking status.pressed_down_with_focus separately from other press status flags. Makes all pressed statuses consistent on toggle buttons with ACTION_MODE_BUTTON_PRESSED. --- scene/gui/base_button.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp index d69ab4c9cb8..1502579a6a3 100644 --- a/scene/gui/base_button.cpp +++ b/scene/gui/base_button.cpp @@ -151,11 +151,13 @@ void BaseButton::_toggled(bool p_pressed) { void BaseButton::on_action_event(Ref p_event) { Ref mouse_button = p_event; - if (!status.pressed_down_with_focus && p_event->is_pressed() && (mouse_button.is_null() || status.hovering)) { + if (p_event->is_pressed() && (mouse_button.is_null() || status.hovering)) { status.press_attempt = true; status.pressing_inside = true; - status.pressed_down_with_focus = true; - emit_signal(SNAME("button_down")); + if (!status.pressed_down_with_focus) { + status.pressed_down_with_focus = true; + emit_signal(SNAME("button_down")); + } } if (status.press_attempt && status.pressing_inside) { @@ -181,11 +183,13 @@ void BaseButton::on_action_event(Ref p_event) { } } - if (status.pressed_down_with_focus && !p_event->is_pressed()) { + if (!p_event->is_pressed()) { status.press_attempt = false; status.pressing_inside = false; - status.pressed_down_with_focus = false; - emit_signal(SNAME("button_up")); + if (status.pressed_down_with_focus) { + status.pressed_down_with_focus = false; + emit_signal(SNAME("button_up")); + } } queue_redraw();