When a user clicks on Axis (x or y), ChartModifierBase.OnModifierMouseDown is called. As axis are outside of chart zoom area, this should not be called. Is there anyway to know that ChartModifierBase.OnModifierMouseDown is on axis and not on chart area?
- manishdoshi asked 12 years ago
- You must login to post comments
Hi Manish,
As modifiers can perform operations on the axes, its correct behaviour that ChartModifierBase receives an OnModifierMouseDown event when the mouse is clicked on an axis.
Internally, to check whether the mouse point is inside the main chart area (i.e. not on an axis), RubberBandXyZoomModifier has this code:
public override void OnModifierMouseDown(ModifierMouseArgs e) { if (_isDragging || e.MouseButtons != MouseButtons.Left) return; var modifierSurfaceBounds = ModifierSurface.GetBoundsRelativeTo(RootGrid); bool isClickOnChart = modifierSurfaceBounds.Contains(e.MousePoint); // Exit if the mouse down was outside the bounds of the ModifierSurface if (!isClickOnChart) return; // ... }
It sounds like you are creating a custom modifier. If so please be aware that all mouse points that are sent to the OnModifierMouse* methods are relative to the parent SciChartSurface.RootGrid. If you wanted to get a mouse point relative to the chart area itself, you can use this code:
// Translate the mouse point (which is in RootGrid coordinates) relative to the ModifierSurface // This accounts for any offset due to left Y-Axis var ptTrans = RootGrid.TranslatePoint(e.MousePoint, ModifierSurface);
- Andrew Burnett-Thompson answered 12 years ago
- You must login to post comments
Please login first to submit.