Page 1 of 1
ColorLine onMouseOver/onClick event?
Posted: Mon Mar 15, 2010 10:44 am
by 15654539
Hi,
I would like to detect when the user's mouse is over a ColorLine, or when click it to show a tooltip. But I only found EndDragLine and DragLine, and I don't want the user move it to show the tooltip. Any Ideas?
Thanks
Re: ColorLine onMouseOver/onClick event?
Posted: Mon Mar 15, 2010 3:20 pm
by yeray
Hi wakeup,
Have you tried with the MouseMove event with the tool clicked method?
Code: Select all
Steema.TeeChart.Tools.ColorLine colorline1;
Steema.TeeChart.Tools.Annotation annotation1;
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
line1.FillSampleValues();
colorline1 = new Steema.TeeChart.Tools.ColorLine(tChart1.Chart);
colorline1.Axis = tChart1.Axes.Bottom;
colorline1.Value = 10;
annotation1 = new Steema.TeeChart.Tools.Annotation(tChart1.Chart);
annotation1.Active = false;
colorline1.ColorLineClickTolerance = 5;
tChart1.MouseMove += new MouseEventHandler(tChart1_MouseMove);
}
void tChart1_MouseMove(object sender, MouseEventArgs e)
{
if /*(colorline1.Clicked(e.X, e.Y))*/ (Math.Abs(e.X - colorline1.Axis.CalcPosValue(colorline1.Value)) == colorline1.ColorLineClickTolerance)
{
annotation1.Text = "colorline1 value: " + colorline1.Value.ToString();
annotation1.Top = e.Y;
annotation1.Left = e.X;
annotation1.Active = true;
tChart1.Refresh();
}
else annotation1.Active = false;
}
It seems that the colorline clicked method doesn't return the correct value, that's I used "(Math.Abs(e.X - colorline1.Axis.CalcPosValue(colorline1.Value)) == colorline1.ColorLineClickTolerance)" instead of it. Could you please confirm that the clicked method doesn't work as expected?
Re: ColorLine onMouseOver/onClick event?
Posted: Mon Mar 15, 2010 4:20 pm
by 15654539
Sorry. My the type of my chart.MouseMove is EventHandler and not MouseEventHandler. So I can't get e.X, e.Y values...
What have I different? I'm woring with Visual studio 2008 and the the last version of teechart.net
Thanks
Re: ColorLine onMouseOver/onClick event?
Posted: Tue Mar 16, 2010 3:54 pm
by yeray
Hi wakeup,
Are you programming on C++? Here, creating the event at designtime it looks as follows:
Code: Select all
this->tChart1->MouseMove += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::tChart1_MouseMove);
//...
private: System::Void tChart1_MouseMove(System::Object^ sender, System::Windows::Forms::MouseEventArgs^ e) {
}
Re: ColorLine onMouseOver/onClick event?
Posted: Wed Mar 17, 2010 7:33 am
by 15654539
No, I'm programming in C#
thanks!
Re: ColorLine onMouseOver/onClick event?
Posted: Wed Mar 17, 2010 9:39 am
by yeray
Hi wakeup,
It's strange. Have you tried the code I posted above in a new testing WinForms project (File\New\Project...\Visual C#\Windows Forms Application)?
Re: ColorLine onMouseOver/onClick event?
Posted: Wed Mar 17, 2010 5:24 pm
by 15654539
Oh! Sorry. I was using the mouseOver event instead of mouseMove. Now it runs.
But it doen't run with the colorline1.Clicked condition
Re: ColorLine onMouseOver/onClick event?
Posted: Thu Mar 18, 2010 1:33 pm
by yeray
Hi wakeup,
Thanks, I've added it to the defect list to be fixed in future releases (TF02014736).