1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:08:12 +00:00

LibGUI: Fix TreeView scrolling to top when clicking sub-items

This code was confusing two different versions of scroll_into_view that
were getting mixed up due to member function shadowing.

Adding an "override" to the subclass declaration exposed the problem.

With this fixed, we no longer lose our scroll position wildly when
using the mouse to select TreeView items.
This commit is contained in:
Andreas Kling 2020-09-16 15:28:16 +02:00
parent d1445cee6d
commit 95b6c98435
3 changed files with 9 additions and 9 deletions

View file

@ -277,7 +277,7 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio
// Reselect the existing folder in the tree.
auto new_index = directories_model->index(current_path, GUI::FileSystemModel::Column::Name);
tree_view.selection().set(new_index);
tree_view.scroll_into_view(new_index, Orientation::Vertical);
tree_view.scroll_into_view(new_index, false, true);
tree_view.update();
directory_view.refresh();
@ -549,7 +549,7 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio
auto new_index = directories_model->index(new_path, GUI::FileSystemModel::Column::Name);
if (new_index.is_valid()) {
tree_view.selection().set(new_index);
tree_view.scroll_into_view(new_index, Orientation::Vertical);
tree_view.scroll_into_view(new_index, false, true);
tree_view.update();
}