Skip to content

Commit bfa351c

Browse files
committed
Merge pull request #101246 from wlsnmrk/dropdown-fix
Fix menus and dropdowns requiring two clicks
2 parents 21721ae + 5fad891 commit bfa351c

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

scene/gui/base_button.cpp

+10-6
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,13 @@ void BaseButton::_toggled(bool p_pressed) {
151151
void BaseButton::on_action_event(Ref<InputEvent> p_event) {
152152
Ref<InputEventMouseButton> mouse_button = p_event;
153153

154-
if (!status.pressed_down_with_focus && p_event->is_pressed() && (mouse_button.is_null() || status.hovering)) {
154+
if (p_event->is_pressed() && (mouse_button.is_null() || status.hovering)) {
155155
status.press_attempt = true;
156156
status.pressing_inside = true;
157-
status.pressed_down_with_focus = true;
158-
emit_signal(SNAME("button_down"));
157+
if (!status.pressed_down_with_focus) {
158+
status.pressed_down_with_focus = true;
159+
emit_signal(SNAME("button_down"));
160+
}
159161
}
160162

161163
if (status.press_attempt && status.pressing_inside) {
@@ -181,11 +183,13 @@ void BaseButton::on_action_event(Ref<InputEvent> p_event) {
181183
}
182184
}
183185

184-
if (status.pressed_down_with_focus && !p_event->is_pressed()) {
186+
if (!p_event->is_pressed()) {
185187
status.press_attempt = false;
186188
status.pressing_inside = false;
187-
status.pressed_down_with_focus = false;
188-
emit_signal(SNAME("button_up"));
189+
if (status.pressed_down_with_focus) {
190+
status.pressed_down_with_focus = false;
191+
emit_signal(SNAME("button_up"));
192+
}
189193
}
190194

191195
queue_redraw();

0 commit comments

Comments
 (0)