Merge pull request #101246 from wlsnmrk/dropdown-fix

Fix menus and dropdowns requiring two clicks
This commit is contained in:
Rémi Verschelde 2025-01-08 18:20:07 +01:00
commit bfa351cb44

View file

@ -151,11 +151,13 @@ void BaseButton::_toggled(bool p_pressed) {
void BaseButton::on_action_event(Ref<InputEvent> p_event) {
Ref<InputEventMouseButton> 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<InputEvent> 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();