mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-26 22:38:51 +00:00
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
This commit is contained in:
parent
ad8284bac6
commit
a7533eb29c
Notes:
sideshowbarker
2024-07-19 02:01:34 +09:00
Author: https://github.com/tomuta
Commit: a7533eb29c
Pull-request: https://github.com/SerenityOS/serenity/pull/3698
Issue: https://github.com/SerenityOS/serenity/issues/3665
2 changed files with 8 additions and 1 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue