mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
LibGUI: Improve TreeView keyboard navigation
This commit adds two new behaviour to the key event handler of the TreeView widget: Pressing left now jumps to the parent node if the current treenode is closed or has no children. Pressing right now jumps to the first children node if the current treenode is open.
This commit is contained in:
parent
b6887bd9cd
commit
2eb9620415
Notes:
sideshowbarker
2024-07-19 09:10:54 +09:00
Author: https://github.com/xTibor Commit: https://github.com/SerenityOS/serenity/commit/2eb9620415f Pull-request: https://github.com/SerenityOS/serenity/pull/1268
1 changed files with 11 additions and 2 deletions
|
@ -417,8 +417,13 @@ void TreeView::keydown_event(KeyEvent& event)
|
|||
if (event.key() == KeyCode::Key_Left) {
|
||||
if (cursor_index.is_valid() && model()->row_count(cursor_index)) {
|
||||
auto& metadata = ensure_metadata_for_index(cursor_index);
|
||||
if (metadata.open)
|
||||
if (metadata.open) {
|
||||
open_tree_node(false, metadata);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (cursor_index.is_valid() && cursor_index.parent().is_valid()) {
|
||||
selection().set(cursor_index.parent());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -426,8 +431,12 @@ void TreeView::keydown_event(KeyEvent& event)
|
|||
if (event.key() == KeyCode::Key_Right) {
|
||||
if (cursor_index.is_valid() && model()->row_count(cursor_index)) {
|
||||
auto& metadata = ensure_metadata_for_index(cursor_index);
|
||||
if (!metadata.open)
|
||||
if (!metadata.open) {
|
||||
open_tree_node(true, metadata);
|
||||
return;
|
||||
}
|
||||
|
||||
selection().set(model()->index(0, model()->tree_column(), cursor_index));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue