feat: implement TreeState select first/last
This commit is contained in:
1 parent
c0e4967b88
commit
b01956741b
3 files changed
+26
-1
No files matched your search
+15
@@ -86,6 +86,21 @@ impl TreeState {
|
||||
self.opened.clear();
|
||||
}
|
||||
|
||||
/// Select the first node.
|
||||
pub fn select_first(&mut self) {
|
||||
self.select(vec![0]);
|
||||
}
|
||||
|
||||
/// Select the last node.
|
||||
pub fn select_last(&mut self, items: &[TreeItem]) {
|
||||
let visible = flatten(&self.get_all_opened(), items);
|
||||
let new_identifier = visible
|
||||
.last()
|
||||
.map(|o| o.identifier.clone())
|
||||
.unwrap_or_default();
|
||||
self.select(new_identifier);
|
||||
}
|
||||
|
||||
/// Handles the up arrow key.
|
||||
/// Moves up in the current depth or to its parent.
|
||||
pub fn key_up(&mut self, items: &[TreeItem]) {
|
||||
|
||||
Reference in new issue
Block a user