oxyplot-xamarin
oxyplot-xamarin copied to clipboard
MouseDown event does not fire on Xamarin Mac graph points
I am trying to implement a handling clicks on points marked on the graph in Xamarin Mac application. However, the MouseDown event is never call when a point displayed on the graph is clicked. The same code works fine on Windows version of the same application.
var pointAnnotation = new LineSeries { Title = GetYAxisName(graphType), StrokeThickness = 0, LineLegendPosition = LineLegendPosition.None, MarkerFill = OxyColors.DarkTurquoise, MarkerStroke = OxyColors.DarkTurquoise, MarkerType = MarkerType.Circle, TrackerKey = "Calculations", MarkerSize = 5 };
/// Adding points in the loop pointAnnotation.Points.Add(new DataPoint((double)valueX, (double)valueY); //
//adding event handler
pointAnnotation.MouseDown += (s, e) =>
{
if (e.ChangedButton == OxyMouseButton.Left)
{
e.Handled = true;
}
};
@pkoscierzynski You need to add an NSTrackingArea to the PlotView with NSView.AddTrackingArea. Something like:
var options = NSTrackingAreaOptions.ActiveAlways | NSTrackingAreaOptions.MouseEnteredAndExited | NSTrackingAreaOptions.InVisibleRect | NSTrackingAreaOptions.MouseMoved;
plotView.AddTrackingArea(new NSTrackingArea(plotView.Bounds, options, plotView, null);