mirror of
https://github.com/RGBCube/serenity
synced 2025-05-21 15:25:07 +00:00
LibGUI: Preserve existing GItemView selection on rubber band (#1031)
This commit is contained in:
parent
5387a19268
commit
dcc4704fb5
2 changed files with 14 additions and 1 deletions
|
@ -116,7 +116,13 @@ void GItemView::mousedown_event(GMouseEvent& event)
|
|||
if (event.button() == GMouseButton::Left) {
|
||||
m_left_mousedown_position = event.position();
|
||||
if (item_index == -1) {
|
||||
selection().clear();
|
||||
if(event.modifiers() & Mod_Ctrl) {
|
||||
selection().for_each_index([&](auto& index) {
|
||||
m_rubber_band_remembered_selection.append(index);
|
||||
});
|
||||
} else {
|
||||
selection().clear();
|
||||
}
|
||||
m_rubber_banding = true;
|
||||
m_rubber_band_origin = event.position();
|
||||
m_rubber_band_current = event.position();
|
||||
|
@ -136,6 +142,7 @@ void GItemView::mouseup_event(GMouseEvent& event)
|
|||
{
|
||||
if (m_rubber_banding && event.button() == GMouseButton::Left) {
|
||||
m_rubber_banding = false;
|
||||
m_rubber_band_remembered_selection.clear();
|
||||
update();
|
||||
return;
|
||||
}
|
||||
|
@ -155,6 +162,11 @@ void GItemView::mousemove_event(GMouseEvent& event)
|
|||
for (auto item_index : items_intersecting_rect(rubber_band_rect)) {
|
||||
selection().add(model()->index(item_index, model_column()));
|
||||
}
|
||||
if(event.modifiers() & Mod_Ctrl) {
|
||||
for (auto storeditem : m_rubber_band_remembered_selection) {
|
||||
selection().add(storeditem);
|
||||
}
|
||||
}
|
||||
update();
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue