Interface IGraphHitTester
Hit tester for the entire graph surface. Aggregates hit tests across all element types with proper priority ordering.
Hit Test Priority Order (first match wins):
- Resize handles (highest priority - always on top)
- Ports (small targets need priority)
- Nodes (front to back by Z-order)
- Edges (may need tolerance-based hit testing)
- Groups (behind their contents)
- Canvas (empty space, lowest priority)
Inspired by:
- react-diagrams: DiagramEngine.getModelAtPosition() with type filtering
- Konva.js: Stage.getIntersection() returning topmost shape
- draw.io/mxGraph: mxGraph.getCellAt() with priority handling
public interface IGraphHitTester
Properties
InputCoordinateSpace
The coordinate space expected for hit test inputs.
Standard implementations expect Canvas coordinates. Callers using screen coordinates (e.g., from pointer events) must convert using ScreenToCanvas(double, double) first.
CoordinateSpace InputCoordinateSpace { get; }
Property Value
Methods
HitTest(Point)
Performs a comprehensive hit test against all graph elements.
GraphHitTestResult HitTest(Point position)
Parameters
positionPointPosition to test in the coordinate space specified by InputCoordinateSpace.
Returns
- GraphHitTestResult
The hit test result identifying what was hit. If nothing specific was hit, returns a result with Canvas.
HitTest(Point, params HitTargetType[])
Performs a hit test filtering to specific element types.
GraphHitTestResult HitTest(Point position, params HitTargetType[] targetTypes)
Parameters
positionPointPosition to test.
targetTypesHitTargetType[]Which element types to consider.
Returns
- GraphHitTestResult
The hit test result, only matching specified types.
HitTest(Point, double, double, double)
Performs a hit test with custom tolerance values.
GraphHitTestResult HitTest(Point position, double nodeTolerance = 0, double edgeTolerance = 5, double portTolerance = 8)
Parameters
positionPointPosition to test.
nodeTolerancedoubleExtra tolerance for node bounds.
edgeTolerancedoubleExtra tolerance for edge paths.
portTolerancedoubleExtra tolerance for port targets.
Returns
- GraphHitTestResult
The hit test result.