Page 1 of 1

Chart OnClickSeries not working as expected

Posted: Thu Mar 29, 2018 9:41 am
by 16580540
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

Re: Chart OnClickSeries not working as expected

Posted: Tue Apr 03, 2018 6:39 am
by yeray
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;