loadEventHandlers method
Loads this component event handlers. Call super to check whether this component has been attached. If it hasn't, it will throw ComponentNotRenderedException.
Because this is a StringComponent, this method is not called as this component never gets rendered independently. The parent needs to call this typically during postRender.
BUG: There might need a way for this to be called automatically after attached.
Implementation
@override
void loadEventHandlers() {
void onMouse(MouseEvent event) {
var minX = getLabelMinX();
var minY = getLabelMinY();
var maxX = getLabelMaxX();
var maxY = getLabelMaxY();
for (var pointSet in _hoverPaths.entries) {
for (var entry in pointSet.value.entries) {
var point = entry.key;
var dot = entry.value;
// TODO: ensure it is right to call isPointInPath this way
if (ctx.isPointInPath(dot, event.offsetX, event.offsetY.toJS)) {
onPointHover(pointSet.key,
point.key,
point.value,
lerp(point.key, minX, maxX, gridMinPxX, gridMaxPxX),
lerp(point.value, minY, maxY, gridMaxPxY, gridMinPxY));
return;
}
}
}
onPointHoverOut();
}
super.loadEventHandlers();
_onMouseMoveSubs = _svgElem.onMouseMove.listen(onMouse);
_onMouseClickSubs = _svgElem.onClick.listen(onMouse);
_onCaptionClickSubs = _captionElem.onClick.listen((event) {
_hideCaption();
});
}