hitTest method
Performs hit testing at a point.
Tests in priority order matching visual z-order (top to bottom): foreground annotations → ports → nodes → connections → background annotations → canvas
This order ensures that elements visually on top receive hit priority. Foreground annotations (stickies, markers) are above everything except the interaction layer. Background annotations (groups) are behind nodes/connections.
Implementation
HitTestResult hitTest(Offset point) {
// 1. Foreground annotations (highest priority - visually on top)
final foregroundResult = _hitTestAnnotations(point, foreground: true);
if (foregroundResult != null) return foregroundResult;
// 2. Ports
final portResult = _hitTestPorts(point);
if (portResult != null) return portResult;
// 3. Nodes
final nodeResult = _hitTestNodes(point);
if (nodeResult != null) return nodeResult;
// 4. Connections
final connectionResult = _hitTestConnections(point);
if (connectionResult != null) return connectionResult;
// 5. Background annotations (groups - behind nodes/connections)
final backgroundResult = _hitTestAnnotations(point, foreground: false);
if (backgroundResult != null) return backgroundResult;
// 6. Canvas (background)
return const HitTestResult(hitType: HitTarget.canvas);
}