mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:38:11 +00:00
LibGUI: Tweak selection modification behavior on context menu event
Before bringing up the context menu, clicking... - ...on an already selected item leaves selection alone - ...on an unselected item makes it the only selected item - ...outside any item clears the selection
This commit is contained in:
parent
f1c4b65089
commit
f360858836
2 changed files with 10 additions and 8 deletions
|
@ -105,8 +105,10 @@ void GItemView::context_menu_event(GContextMenuEvent& event)
|
||||||
GModelIndex index;
|
GModelIndex index;
|
||||||
if (item_index != -1) {
|
if (item_index != -1) {
|
||||||
index = model()->index(item_index, m_model_column);
|
index = model()->index(item_index, m_model_column);
|
||||||
selection().add(index);
|
if (!selection().contains(index))
|
||||||
update();
|
selection().set(index);
|
||||||
|
} else {
|
||||||
|
selection().clear();
|
||||||
}
|
}
|
||||||
if (on_context_menu_request)
|
if (on_context_menu_request)
|
||||||
on_context_menu_request(index, event);
|
on_context_menu_request(index, event);
|
||||||
|
|
|
@ -517,12 +517,12 @@ void GTableView::context_menu_event(GContextMenuEvent& event)
|
||||||
}
|
}
|
||||||
|
|
||||||
auto index = index_at_event_position(event.position());
|
auto index = index_at_event_position(event.position());
|
||||||
if (!index.is_valid())
|
if (index.is_valid()) {
|
||||||
return;
|
if (!selection().contains(index))
|
||||||
dbgprintf("context menu requested for index (%d,%d) '%s'\n", index.row(), index.column(), model()->data(index).to_string().characters());
|
selection().set(index);
|
||||||
|
} else {
|
||||||
selection().set(index);
|
selection().clear();
|
||||||
update();
|
}
|
||||||
if (on_context_menu_request)
|
if (on_context_menu_request)
|
||||||
on_context_menu_request(index, event);
|
on_context_menu_request(index, event);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue