oxyplot-xamarin icon indicating copy to clipboard operation
oxyplot-xamarin copied to clipboard

MouseDown event does not fire on Xamarin Mac graph points

Open pkoscierzynski opened this issue 8 years ago • 1 comments

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 avatar Sep 16 '16 15:09 pkoscierzynski

@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);

chaselal avatar Jul 23 '18 21:07 chaselal