How to detect user double click on x axis area or Y axis are

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Herman
Newbie
Newbie
Posts: 56
Joined: Tue Dec 07, 2004 5:00 am

How to detect user double click on x axis area or Y axis are

Post by Herman » Mon Sep 26, 2005 8:52 am

How to detect if user double click on x axis area or Y axis area?
Any event I can use?

Thank you

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Mon Sep 26, 2005 9:00 am

Hi Herman,

You can use TChart's OnClickAxis event.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Herman
Newbie
Newbie
Posts: 56
Joined: Tue Dec 07, 2004 5:00 am

Post by Herman » Tue Sep 27, 2005 10:32 am

ummm but I want to detect it on double click event instead of just clicking.
And clickaxis seems to be work when i click precisely on the axis line, what if i click on area near the axis line (outside the axis for sure, not inside) but still have the same effect. Possible?

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Sep 27, 2005 11:15 am

Hi Herman,
ummm but I want to detect it on double click event instead of just clicking.
Yes, but it's easier with some events which already provide mouse coordinates on their arguments list.
And clickaxis seems to be work when i click precisely on the axis line, what if i click on area near the axis line (outside the axis for sure, not inside) but still have the same effect. Possible?
Yes, you can do something like:

Code: Select all

procedure TForm1.Chart1DblClick(Sender: TObject);
var
  Top,Bottom,Left,Right: Integer;
  MousePos: TPoint;
begin
  Top:=Chart1.Axes.Left.IStartPos;
  Bottom:=Chart1.Axes.Left.IEndPos;
  Left:=Chart1.Axes.Left.PosAxis-30;
  Right:=Chart1.Axes.Left.PosAxis;

  MousePos:=Chart1.GetCursorPos;

  if ((MousePos.X>=Left) and (MousePos.X<=Right) and
      (MousePos.Y>=Top) and (MousePos.Y<=Bottom)) then
    Chart1.Title.Text[0]:='Left Axis Clicked!'
  else Chart1.Title.Text[0]:= IntToStr(Top)+', ' +
                          IntToStr(Bottom)+', ' +
                          IntToStr(Left)+', ' +
                          IntToStr(Right);
end;
or

Code: Select all

procedure TForm1.Chart1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
  Top,Bottom,Left,Right: Integer;
begin
  Top:=Chart1.Axes.Left.IStartPos;
  Bottom:=Chart1.Axes.Left.IEndPos;
  Left:=Chart1.Axes.Left.PosAxis-30;
  Right:=Chart1.Axes.Left.PosAxis;

  if ((X>=Left) and (X<=Right) and (Y>=Top) and (Y<=Bottom)) then
    Chart1.Title.Text[0]:='Left Axis Clicked!'
  else Chart1.Title.Text[0]:= IntToStr(Top)+', ' +
                          IntToStr(Bottom)+', ' +
                          IntToStr(Left)+', ' +
                          IntToStr(Right);
end;
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply