This is a migrated thread and some comments may be shown as answers.

ChartTrackBallBehavior, move the ball only on mouse click

1 Answer 52 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
sp09
Top achievements
Rank 1
sp09 asked on 14 Apr 2015, 08:58 PM

Hi,

I am new to telerik controls. I am using ChartTrackBallBehavior on RadCartesianChart. By default the trackball moves with the mouse motion on the chart. Instead of it, I want the trackball to move only on mouse left click on chart. How can I disable the trackball movement with mouse left/right motion event?

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 17 Apr 2015, 09:22 AM
Hello Sonam,

You can achieve your requirement by using the Position property of the TrackBallBehavior. Basically you can subscribe for the MouseLeftButtonDown event of the chart and inside its handler get the current mouse position and set it as the trackball's Position. However, this won't prevent the moving of the trackball on mouse move. To resolve this you can save the previously clicked position and set it in the PositionChanging event handler of the behavior. Here is an example in code:
private Point currentPosition;
private void ChartTrackBallBehavior_PositionChanging(object sender, TrackBallPositionChangingEventArgs e)
{
    e.NewPosition = currentPosition;
}
 
private void chart_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
    currentPosition = e.GetPosition(this.chart);
    this.trackBallBehavior.Position = currentPosition;
}

Please give this approach a try and let me know if it works for you.

Regards,
Martin
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
Tags
General Discussions
Asked by
sp09
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or