Change mouse cursor when hovering over a point


https://www.nevron.com/Forum/Topic9415.aspx
Print Topic | Close Window

By Kevin Harrison - 9 Years Ago
Hi
I have a line chart where some of the series allow dragging of their points. I have changed the cursor of the NDataPointDragTool to be a vertical bar, which works when the user starts to drag the point. However, I want to indicate to the user that the point can be dragged by changing the cursor when they hover over the point. How do I achieve this?

Thanks

Kevin
By Nevron Support - 9 Years Ago
Hi Kevin,

You can create a custom tool that performs a hit test on mouse move - for example:

 [Serializable]
 public class MyCustomTool : NTool
 {
  #region Construcotrs

  public MyCustomTool()
  {
  }

  #endregion

  #region Overrides


  public override void OnMouseMove(object sender, NMouseEventArgs e)
  {
   NControlView view = (NControlView)this.GetView();

   NHitTestCacheService hitTestService = GetView().GetServiceOfType(typeof(NHitTestCacheService)) as NHitTestCacheService;

   if (hitTestService == null)
    return;

   NHitTestResult result = new NHitTestResult(hitTestService.HitTest(new NPointF(e.X, e.Y)) as NChartNode);
   INMouseService mouseService = (INMouseService)GetView().GetServiceOfType(typeof(INMouseService));

   if (result.ChartElement == ChartElement.DataPoint)
   {
    mouseService.Cursor = Cursors.SizeAll;
   }
   else
   {
    mouseService.Cursor = mouseService.DefaultCursor;
   }
   
  }

  #endregion
 }

The above code changes the mouse cursor when the mouse is over a data point. Hope this helps - lets us know if you meet any problems.
By Kevin Harrison - 9 Years Ago
Thanks for the example code.
One problem: this.GetView() doesn't exist in the version I am using.
Is it a recent addition?
Thanks
Kevin
By Nevron Support - 9 Years Ago
Hi Kevin,

Yes - this changed a bit after we added a better WPF integration to the control - before it was just m_View.