Skip to content

Commit

Permalink
Merge pull request #89926 from Sauermann/fix-button-mask-special-case
Browse files Browse the repository at this point in the history
Fix a special case for button masks
  • Loading branch information
akien-mga committed Apr 4, 2024
2 parents 32dcaa0 + 48ea019 commit 4abe918
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions scene/main/viewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1705,9 +1705,10 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {

Point2 mpos = mb->get_position();
if (mb->is_pressed()) {
if (!gui.mouse_focus_mask.is_empty()) {
// Do not steal mouse focus and stuff while a focus mask exists.
gui.mouse_focus_mask.set_flag(mouse_button_to_mask(mb->get_button_index()));
MouseButtonMask button_mask = mouse_button_to_mask(mb->get_button_index());
if (!gui.mouse_focus_mask.is_empty() && !gui.mouse_focus_mask.has_flag(button_mask)) {
// Do not steal mouse focus and stuff while a focus mask without the current mouse button exists.
gui.mouse_focus_mask.set_flag(button_mask);
} else {
gui.mouse_focus = gui_find_control(mpos);
gui.last_mouse_focus = gui.mouse_focus;
Expand Down
1 change: 1 addition & 0 deletions tests/scene/test_code_edit.h
Original file line number Diff line number Diff line change
Expand Up @@ -3520,6 +3520,7 @@ TEST_CASE("[SceneTree][CodeEdit] completion") {
/* Single click selects. */
caret_pos.y += code_edit->get_line_height() * 2;
SEND_GUI_MOUSE_BUTTON_EVENT(caret_pos, MouseButton::LEFT, MouseButtonMask::LEFT, Key::NONE);
SEND_GUI_MOUSE_BUTTON_RELEASED_EVENT(caret_pos, MouseButton::LEFT, MouseButtonMask::NONE, Key::NONE);
CHECK(code_edit->get_code_completion_selected_index() == 2);

/* Double click inserts. */
Expand Down

0 comments on commit 4abe918

Please sign in to comment.