mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 18:28:12 +00:00
LibGUI/TreeView: Select parent on collapse
When collapsing a tree that contains the current selection, the parent node becomes selected instead.
This commit is contained in:
parent
67a5e9f018
commit
7a4445a1fe
3 changed files with 16 additions and 0 deletions
|
@ -148,6 +148,10 @@ void TreeView::toggle_index(const ModelIndex& index)
|
|||
VERIFY(model()->row_count(index));
|
||||
auto& metadata = ensure_metadata_for_index(index);
|
||||
metadata.open = !metadata.open;
|
||||
|
||||
if (!metadata.open && index.is_parent_of(cursor_index()))
|
||||
set_cursor(index, SelectionUpdate::Set);
|
||||
|
||||
if (on_toggle)
|
||||
on_toggle(index, metadata.open);
|
||||
update_column_sizes();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue