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
- OnClickShape
- OnClickConnection
- OnClickBackground
Fired when any node is clicked:
From TeeTree.pas line 2217:
property OnClickShape: TClickShapeEventNode-Level Events
Individual nodes can have their own event handlers:Double-Click Events
Handle double-click interactions:Mouse Move Events
Keyboard Events
OnKeyDown Event
Handle keyboard input: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: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.
