Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Steema/TeeTree/llms.txt

Use this file to discover all available pages before exploring further.

Once you’ve created nodes, TeeTree provides extensive APIs to manipulate, navigate, and manage them. This guide covers essential node operations.

Node Properties

Every TTreeNodeShape is a full component with comprehensive properties.

Position and Size

// Direct position control
Node.X0 := 100;  // Left
Node.Y0 := 50;   // Top
Node.X1 := 300;  // Right
Node.Y1 := 150;  // Bottom

// Or use aliases
Node.Left := 100;
Node.Top := 50;
Node.Width := 200;
Node.Height := 100;

Text Content

// Single line text (property)
Node.SimpleText := 'Quick text';

// Multi-line text (TStringList)
Node.Text.Clear;
Node.Text.Add('First line');
Node.Text.Add('Second line');
Node.Text.Add('Third line');

// Assign from TStrings
Node.Text.Assign(Memo1.Lines);

Visibility and State

// Visibility
Node.Visible := True;
Node.Show;
Node.Hide;

// Expansion state
Node.Expanded := True;
Node.Toggle;  // Toggle expansion

// Selection
Node.Selected := True;
Tree1.Selected.Clear;  // Unselect all

// Checked state (for checkbox nodes)
Node.Checked := True;
Node.ToggleCheck;
The Visible property determines if a node is drawn. If a parent is collapsed, children have Visible = False automatically.

Parent-Child Navigation

// Get parent node
if Assigned(Node.Parent) then
  ShowMessage('Parent: ' + Node.Parent.SimpleText);

// Get root node
RootNode := Node.Root;

Tree Navigation

// Access root nodes
for i := 0 to Tree1.Roots.Count - 1 do
  ProcessNode(Tree1.Roots[i]);

// Access all nodes
for i := 0 to Tree1.Shapes.Count - 1 do
  ProcessNode(Tree1.Shapes[i]);

// Using default array property
Node := Tree1[0];  // First node in tree

Finding Nodes

1

Find by Text

Search for nodes by their text content:
// Exact match
Node := Tree1.Shapes.Find('MyNode', False);

// Partial match
Node := Tree1.Shapes.Find('My', True);

if Assigned(Node) then
  Node.Selected := True;
2

Find by Object

Search for nodes by associated TagObject:
Node := Tree1.Shapes.FindObject(MyObject);
3

Find by Click

Determine which node was clicked:
procedure Tree1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
var Node: TTreeNodeShape;
begin
  Node := Tree1.Shapes.Clicked(X, Y);
  if Assigned(Node) then
    Label1.Caption := 'Node: ' + Node.SimpleText
  else
    Label1.Caption := '';
end;

Manipulating Nodes

Moving Nodes

// Move node and its children
Node.MoveRelative(50, 30, True);

// Move only the node
Node.MoveRelative(50, 30, False);

Resizing Nodes

// Interactive resize
Node.Resize(rcRightBottom, 20, 10);

// Direct size change
Node.Width := Node.Width + 50;
Node.Height := Node.Height + 20;

Z-Order Management

// Bring to front
Node.BringToFront;

// Send to back  
Node.SendToBack;

Iterating Through Nodes

Using ForEach

procedure ProcessNode(Sender: TTreeNodeShape);
begin
  // Process each node
  Sender.Color := clYellow;
end;

begin
  // Apply to all nodes
  Tree1.Shapes.ForEach(ProcessNode);
  
  // Apply to children only
  MyNode.Children.ForEach(ProcessNode);
end;

Manual Iteration

var i: Integer;
begin
  // Iterate all nodes
  for i := 0 to Tree1.Shapes.Count - 1 do
  begin
    Tree1.Shapes[i].Color := clWhite;
  end;
  
  // Iterate children
  for i := 0 to ParentNode.Count - 1 do
  begin
    ParentNode.Children[i].Visible := True;
  end;
end;

Expanding and Collapsing

// Expand/collapse one node
Node.Expanded := True;
Node.Expanded := False;

// Toggle
Node.Toggle;

Sorting Nodes

// Sort children by text
ParentNode.SortChildsText(True, False);   // Ascending, case sensitive
ParentNode.SortChildsText(False, True);   // Descending, ignore case

// Sort entire node list
Tree1.Shapes.Sort(True, True);  // Ascending, ignore case

Selecting Nodes

// Select single node
Node.Selected := True;

// Unselect all
Tree1.Selected.Clear;

// Select all children
ParentNode.SelectChilds;

// Access selected nodes
if Tree1.Selected.Count > 0 then
  FirstSelected := Tree1.Selected.First;

Editing Node Text

// Start editing
Tree1.StartEditing(Node);

// Check if editing
if Tree1.Editing then
  ShowMessage('Editing in progress');

Deleting Nodes

Deleting a node automatically deletes all its children and associated connections.
// Delete node and children
Node.Free;

// Clear all children
ParentNode.Clear;

// Remove specific child
ParentNode.RemoveChild(ChildNode);

// Clear entire tree
Tree1.Shapes.Clear;

Working with Node Data

Data Property

type
  PMyRecord = ^TMyRecord;
  TMyRecord = record
    ID: Integer;
    Name: string;
  end;

var
  MyData: PMyRecord;
begin
  New(MyData);
  MyData^.ID := 1;
  MyData^.Name := 'Test';
  
  // Associate with node
  Node.Data := MyData;
  
  // Retrieve later
  if Assigned(Node.Data) then
  begin
    MyData := PMyRecord(Node.Data);
    ShowMessage(MyData^.Name);
  end;
end;

TagObject Property

// Associate object (no need to free)
Node.TagObject := MyCustomObject;

// Retrieve
if Assigned(Node.TagObject) then
  MyObj := TMyClass(Node.TagObject);

Getting Node Bounds

var R: TRect;
begin
  // Node bounds
  R := Node.Bounds;
  
  // Adjusted bounds (includes image)
  R := Node.AdjustedRectangle;
  
  // Image position
  R := Node.ImageRect;
  
  // Center coordinates
  CenterX := Node.XCenter;
  CenterY := Node.YCenter;
end;

Level and Hierarchy Info

// Get depth level (0 for root)
NodeLevel := Node.Level;

// Check if inside tree bounds
if Node.InsideTreeBounds then
  ShowMessage('Node is visible in tree viewport');

Next Steps

Build docs developers (and LLMs) love