Skip to main content

Overview

TeeTree provides a rich event system for responding to mouse clicks, keyboard input, and other user interactions. Events are available at both the tree level and individual node/connection level.
Events are defined in TeeTree.pas starting at line 1848. Both VCL and FMX versions share the same event signatures.

Mouse Events

Tree-Level Click Events

Fired when any node is clicked:
From TeeTree.pas line 2217: property OnClickShape: TClickShapeEvent

Node-Level Events

Individual nodes can have their own event handlers:
Node-level OnClick fires after tree-level OnClickShape. Both will execute if both are assigned.

Double-Click Events

Handle double-click interactions:
From TreeEd.pas (lines 4205-4208), the editor sets up these events:

Mouse Move Events

From TeeTree.pas (lines 7990-7995):

Keyboard Events

OnKeyDown Event

Handle keyboard input:
From TeeTree.pas line 2244:

Text Editing Events

1

OnStartEditing

Fired when node text editing begins:
2

OnStopEditing

Fired when editing completes:
From TreeEd.pas (line 4207), the editor uses this:

Selection Events

OnSelectShape and OnUnSelectShape

Expand/Collapse Events

OnExpandingCollapsing

Critical for virtual mode and dynamic trees:
From TeeTree.pas (lines 12654-12657):
The Expand parameter is var - you can modify it to cancel the expand/collapse action.

Advanced Events

OnMovingShape

Fired continuously while dragging:

OnResizingShape

Fired while resizing with handles:

OnAfterDraw

Custom drawing after tree renders:

Event Properties Summary

From TeeTree.pas (lines 2214-2244):

Best Practices

Check for nil

Always check if Sender is assigned before accessing properties.

Use var Parameters

Events with var parameters let you modify behavior (like canceling expand).

BeginUpdate/EndUpdate

Wrap bulk changes in BeginUpdate/EndUpdate for better performance.

Event Order Matters

Node events fire after tree events. Plan your logic accordingly.
The TeeTree editor (TreeEd.pas) is an excellent reference for event handling patterns. See lines 4190-4210 for how events are wired up.