pub struct Tree { /* private fields */ }Expand description
Tree widget for rendering hierarchical data.
Implementations§
Source§impl Tree
impl Tree
Sourcepub fn with_show_root(self, show: bool) -> Self
pub fn with_show_root(self, show: bool) -> Self
Set whether to show the root node.
Sourcepub fn with_guides(self, guides: TreeGuides) -> Self
pub fn with_guides(self, guides: TreeGuides) -> Self
Set the guide character style.
Sourcepub fn with_guide_style(self, style: Style) -> Self
pub fn with_guide_style(self, style: Style) -> Self
Set the style for guide characters.
Sourcepub fn with_label_style(self, style: Style) -> Self
pub fn with_label_style(self, style: Style) -> Self
Set the style for node labels.
Sourcepub fn with_root_style(self, style: Style) -> Self
pub fn with_root_style(self, style: Style) -> Self
Set the style for the root label.
Sourcepub fn with_persistence_id(self, id: impl Into<String>) -> Self
pub fn with_persistence_id(self, id: impl Into<String>) -> Self
Set a persistence ID for state saving.
Sourcepub fn persistence_id(&self) -> Option<&str>
pub fn persistence_id(&self) -> Option<&str>
Get the persistence ID, if set.
Source§impl Tree
impl Tree
Sourcepub fn undo_id(&self) -> UndoWidgetId
pub fn undo_id(&self) -> UndoWidgetId
Get the undo widget ID for this tree.
Sourcepub fn handle_mouse(
&mut self,
event: &MouseEvent,
hit: Option<(HitId, HitRegion, u64)>,
expected_id: HitId,
) -> MouseResult
pub fn handle_mouse( &mut self, event: &MouseEvent, hit: Option<(HitId, HitRegion, u64)>, expected_id: HitId, ) -> MouseResult
Handle a mouse event for this tree.
§Hit data convention
The hit data (u64) encodes the flattened visible row index. When the
tree renders with a hit_id, each visible row registers
HitRegion::Content with data = visible_row_index as u64.
Clicking a parent node (one with children) toggles its expanded state
and returns Activated. Clicking a leaf returns Selected.
§Arguments
event— the mouse event from the terminalhit— result offrame.hit_test(event.x, event.y), if availableexpected_id— theHitIdthis tree was rendered with
Sourcepub fn node_at_visible_index_mut(
&mut self,
target: usize,
) -> Option<&mut TreeNode>
pub fn node_at_visible_index_mut( &mut self, target: usize, ) -> Option<&mut TreeNode>
Get a mutable reference to the node at the given visible (flattened) index.
The traversal order matches render_node(): if show_root is true the
root is row 0; otherwise children of the root are the top-level rows.
Only expanded nodes’ children are visited.