class

Opal::UI::Tree

Inherits Opal::UI::Control < Opal::UI::InputHookable < Opal::UI::Element < Opal::UI::Themable < Reference < Object

Renders an interactive hierarchical tree with branch connectors, expand/collapse support, keyboard navigation, and mouse selection.

Constructors

new(root_nodes : Array(TreeNode) = [] of TreeNode, title : String | Nil = nil, selected_node : TreeNode | Nil = nil)
Source
new(root_node : TreeNode, title : String | Nil = nil, selected_node : TreeNode | Nil = nil)
Source

Class methods

to_string(root_nodes : Array(TreeNode), title : String | Nil = nil, width : Int32 | Nil = nil, color : Bool | Nil = nil, theme : Theme | Nil = nil) : String

Class convenience method returning styled tree string

Source
to_string(root_node : TreeNode, title : String | Nil = nil, width : Int32 | Nil = nil, color : Bool | Nil = nil, theme : Theme | Nil = nil) : String

Overload accepting a single root TreeNode

Source

Instance methods

add(node : TreeNode) : TreeNode
Source
add(label : String, color : Color | Symbol | String = :white, icon : String | Nil = nil) : TreeNode
Source
add(label : String, color : Color | Symbol | String = :white, icon : String | Nil = nil, &) : TreeNode
Source
handle_key(event : Terminal::KeyEvent) : Bool

Default key event handler. Override in subclasses if not using @default_input_proc.

Source
handle_mouse(event : Terminal::MouseEvent) : Bool

Default mouse event handler. Override in subclasses if not using @default_input_proc.

Source
on_select
Source
on_select=(on_select : Proc(TreeNode, Nil) | Nil)
Source
on_toggle
Source
on_toggle=(on_toggle : Proc(TreeNode, Nil) | Nil)
Source
preferred_print_size(available_w : Int32) : Tuple(Int32, Int32)

Preferred size in print mode: full line count

Source
preferred_size(available_w : Int32, available_h : Int32) : Tuple(Int32, Int32)
Source
render(buffer : Buffer, x : Int32, y : Int32, width : Int32, height : Int32) : Nil
Source
render_print(buffer : Buffer, width : Int32, height : Int32) : Nil

Render hook for print mode: clears selection highlight to render pure branch structure

Source
root_nodes
Source
selected_node
Source
selected_node=(selected_node : TreeNode | Nil)
Source
title
Source