I need to allow the user to add timeline live events by clicking with the mouse somewhere in the timeline. Can anyone tell me how to get the time corresponding to a mouse click event?
Regards,
Mathias
2 Answers, 1 is accepted
0
Tsvetie
Telerik team
answered on 23 May 2012, 08:20 AM
Hi Mathias,
In short, the timeline does not offer anything out of the box to help you in this respect. You can, however, use the following logic to calculate the time, corresponding to the mouse click:
Calculate the current visible period, that is timeline.VisiblePeriodEnd - timeline.VisiblePeriodStart.
Get the width of the timeline control.
Calculate the ticks-per-pixel value - just divide the visible period in ticks by the width of the control.
Check the X of the point, where the use clicked and multiply it by the ticks-per-pixel value - this should be the time value that you need.
Please note, that this method is not very accurate and in case you are visualizing a period of over a year, the day, minute, etc. might not be precise.
Kind regards,
Tsvetie
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>