Chart OnClickSeries not working as expected

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
ChristianZiegelt
Newbie
Newbie
Posts: 1
Joined: Fri Mar 17, 2017 12:00 am

Chart OnClickSeries not working as expected

Post by ChristianZiegelt » Thu Mar 29, 2018 9:41 am

Hi all,
I'm currently trying to use the event OnClickSeries() from TChart for a TPointSeries.
Unfortunately, the click event is not always sent.

Marks are enabled in my series. If I click on the mark text or within the marks background, the event is not fired.
Is this the desired behaviour ?
What can I do, to always get the click event if I click on a series item ?

And what is the effect of "ClickTolerance" being "0" or "30"....

Best regards
Christian

Yeray
Site Admin
Site Admin
Posts: 9514
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Chart OnClickSeries not working as expected

Post by Yeray » Tue Apr 03, 2018 6:39 am

Hello,

You could use the Clicked function at the OnClick event to see if the Marks have been clicked. Ie:

Code: Select all

procedure TForm1.Chart1Click(Sender: TObject);
var ValueIndex: Integer;
    MousePos:   TPoint;
begin
  MousePos:=Chart1.GetCursorPos;
  ValueIndex:=Series1.Marks.Clicked(MousePos.X, MousePos.Y);

  if ValueIndex>-1 then
     ShowMessage('Mark clicked: ' + IntToStr(ValueIndex));
end;

procedure TForm1.Chart1ClickSeries(Sender: TCustomChart; Series: TChartSeries;
  ValueIndex: Integer; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  ShowMessage('Point Clicked: ' + IntToStr(ValueIndex));
end;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply