feat: Adding toggle (#8)
* feat: Adding toggle * Update src/lib.rs Return unneded Co-authored-by: EdJoPaTo <github@edjopato.de> Co-authored-by: EdJoPaTo <github@edjopato.de>
This commit is contained in:
+10
@@ -58,6 +58,16 @@ impl TreeState {
|
||||
self.opened.remove(identifier)
|
||||
}
|
||||
|
||||
/// Toggles a tree node.
|
||||
/// If the node is in opened then it calls `close()`. Otherwise it calls `open()`.
|
||||
pub fn toggle(&mut self) {
|
||||
if self.opened.contains(&self.selected()) {
|
||||
self.close(&self.selected());
|
||||
} else {
|
||||
self.open(self.selected());
|
||||
}
|
||||
}
|
||||
|
||||
pub fn close_all(&mut self) {
|
||||
self.opened.clear();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user