summaryrefslogtreecommitdiff
path: root/Libraries/LibGUI/AbstractView.cpp
diff options
context:
space:
mode:
authorTom <tomut@yahoo.com>2020-10-05 20:32:21 -0600
committerAndreas Kling <kling@serenityos.org>2020-10-06 15:04:23 +0200
commita7533eb29cfea6f160a90f58205b8caf93f49d23 (patch)
treefa48833c86a668f911e72ee428fb56fde9815a01 /Libraries/LibGUI/AbstractView.cpp
parentad8284bac680c191f66c2b5b053ba0e73c45072d (diff)
downloadserenity-a7533eb29cfea6f160a90f58205b8caf93f49d23.zip
LibGUI: Clear selection if right-clicking item that isn't selected
If we're right-clicking on an item that isn't currently selected, clear the selection first. Fixes #3665
Diffstat (limited to 'Libraries/LibGUI/AbstractView.cpp')
-rw-r--r--Libraries/LibGUI/AbstractView.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/Libraries/LibGUI/AbstractView.cpp b/Libraries/LibGUI/AbstractView.cpp
index 8daaba7721..1b2d43e1ba 100644
--- a/Libraries/LibGUI/AbstractView.cpp
+++ b/Libraries/LibGUI/AbstractView.cpp
@@ -224,7 +224,9 @@ void AbstractView::mousedown_event(MouseEvent& event)
} else if (event.button() == MouseButton::Left && m_selection.contains(index) && !m_model->drag_data_type().is_null()) {
// We might be starting a drag, so don't throw away other selected items yet.
m_might_drag = true;
- } else if (event.button() != MouseButton::Right) {
+ } else if (event.button() == MouseButton::Right) {
+ set_cursor(index, SelectionUpdate::ClearIfNotSelected);
+ } else {
set_cursor(index, SelectionUpdate::Set);
}
@@ -427,6 +429,10 @@ void AbstractView::set_cursor(ModelIndex index, SelectionUpdate selection_update
set_selection(index);
else if (selection_update == SelectionUpdate::Ctrl)
toggle_selection(index);
+ else if (selection_update == SelectionUpdate::ClearIfNotSelected) {
+ if (!m_selection.contains(index))
+ clear_selection();
+ }
// FIXME: Support the other SelectionUpdate types