onGetNodeForLocation method
void
onGetNodeForLocation(
- int? id,
- Map<String, dynamic> params
)
Implementation
void onGetNodeForLocation(int? id, Map<String, dynamic> params) {
int x = params['x'];
int y = params['y'];
RenderBox rootRenderObject = document.renderer!;
BoxHitTestResult result = BoxHitTestResult();
rootRenderObject.hitTest(result, position: Offset(x.toDouble(), y.toDouble()));
if (result.path.first.target is RenderBoxModel) {
RenderBoxModel lastHitRenderBoxModel = result.path.first.target as RenderBoxModel;
int? targetId = document.controller.view.getTargetIdByEventTarget(lastHitRenderBoxModel.renderStyle.target);
sendToFrontend(id, JSONEncodableMap({
'backendId': targetId,
'frameId': DEFAULT_FRAME_ID,
'nodeId': targetId,
}));
} else {
sendToFrontend(id, null);
}
}