Profile Picture

Change mouse cursor when hovering over a point

Posted By Kevin Harrison 9 Years Ago
Author
Message
Kevin Harrison
Posted 9 Years Ago
View Quick Profile
Supreme Being

Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)

Group: Forum Members
Last Active: 3 Years Ago
Posts: 176, Visits: 1,865
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

Nevron Support
Posted 9 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: 2 Weeks Ago
Posts: 3,054, Visits: 4,015
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.


Best Regards,
Nevron Support Team



Kevin Harrison
Posted 9 Years Ago
View Quick Profile
Supreme Being

Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)Supreme Being (79 reputation)

Group: Forum Members
Last Active: 3 Years Ago
Posts: 176, Visits: 1,865
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

Nevron Support
Posted 9 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: 2 Weeks Ago
Posts: 3,054, Visits: 4,015
Hi Kevin,

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


Best Regards,
Nevron Support Team





Similar Topics


Reading This Topic