Skip to content

Commit

Permalink
Allow a right mouse click to cancel drag-and-drop
Browse files Browse the repository at this point in the history
This is a small usability enhancement, that allows users to cancel
drag-and-drop without the need to press the escape key on the keyboard.
  • Loading branch information
Sauermann committed Dec 10, 2024
1 parent cf038de commit 8775ce2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions scene/main/viewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1742,6 +1742,11 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
if (mb.is_valid()) {
Point2 mpos = mb->get_position();
if (mb->is_pressed()) {
if (gui.dragging && mb->get_button_index() == MouseButton::RIGHT) {
_perform_drop();
set_input_as_handled();
return;
}
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.
Expand Down

0 comments on commit 8775ce2

Please sign in to comment.