summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTibor Nagy <xnagytibor@gmail.com>2020-02-24 14:37:47 +0100
committerAndreas Kling <kling@serenityos.org>2020-02-24 15:12:47 +0100
commit0086daf9b0d3cb3569b76e2b34da8f6df9579bb7 (patch)
treecb381e6836265ba703307ac8d8ee828af391b051
parentcb9d9846e0bc23df99488ceb87ff75a14295de7e (diff)
downloadserenity-0086daf9b0d3cb3569b76e2b34da8f6df9579bb7.zip
LibGUI: Scroll selected treeview entries into view
-rw-r--r--Libraries/LibGUI/TreeView.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/Libraries/LibGUI/TreeView.cpp b/Libraries/LibGUI/TreeView.cpp
index 407560a112..9740ea6534 100644
--- a/Libraries/LibGUI/TreeView.cpp
+++ b/Libraries/LibGUI/TreeView.cpp
@@ -386,6 +386,7 @@ void TreeView::keydown_event(KeyEvent& event)
});
if (found_index.is_valid()) {
selection().set(found_index);
+ scroll_into_view(selection().first(), Orientation::Vertical);
update();
}
return;
@@ -401,8 +402,11 @@ void TreeView::keydown_event(KeyEvent& event)
previous_index = index;
return IterationDecision::Continue;
});
- if (found_index.is_valid())
+ if (found_index.is_valid()) {
selection().set(found_index);
+ scroll_into_view(selection().first(), Orientation::Vertical);
+ update();
+ }
return;
}
@@ -423,6 +427,7 @@ void TreeView::keydown_event(KeyEvent& event)
}
if (cursor_index.is_valid() && cursor_index.parent().is_valid()) {
selection().set(cursor_index.parent());
+ scroll_into_view(selection().first(), Orientation::Vertical);
return;
}
}
@@ -436,6 +441,7 @@ void TreeView::keydown_event(KeyEvent& event)
}
selection().set(model()->index(0, model()->tree_column(), cursor_index));
+ scroll_into_view(selection().first(), Orientation::Vertical);
return;
}
}