Change mouse cursor when hovering over a point


Author
Message
Kevin Harrison 1
Kevin Harrison 1
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
Posts: 176, Visits: 1.9K
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
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.1K
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 1
Kevin Harrison 1
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
Posts: 176, Visits: 1.9K
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
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.1K
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


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic
4 active, 4 guests, 0 members, 0 anonymous
No members currently viewing this topic!

Login

Explore
Messages
Mentions
Search