Skip to content

Commit

Permalink
Merge pull request #101246 from wlsnmrk/dropdown-fix
Browse files Browse the repository at this point in the history
Fix menus and dropdowns requiring two clicks
  • Loading branch information
akien-mga committed Jan 8, 2025
2 parents 21721ae + 5fad891 commit bfa351c
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions scene/gui/base_button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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();
Expand Down

0 comments on commit bfa351c

Please sign in to comment.