Page 1 of 1

Is there a OnMarkClick() event?

Posted: Wed Jun 11, 2014 1:50 am
by 16566869
I am using TPointSeries with setting the Marks visible.
And I want to do sth. when Marks clicked,
is there some event like OnMarkClick()?

Thanks in advance.

Re: Is there a OnMarkClick() event?

Posted: Wed Jun 11, 2014 9:38 am
by yeray
Hello,

There's a clicked function for the Marks, so you could use the Chart's OnMouseDown event as follows:

Code: Select all

procedure TForm1.Chart1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Single);
begin
  Caption:=IntToStr(Chart1[0].Marks.Clicked(Round(X), Round(Y)));
end;

Re: Is there a OnMarkClick() event?

Posted: Sun Jun 15, 2014 2:38 am
by 16566869
Thank you.
And one more question about TAxisArrowTool.
I want to know if TChart or TAxisArrowTool is doubleclicked.

And the events were triggled as below when the TAxisArrowTool doubleclicked.
So I set a flag for TAxisArrowToolClick (1), then check the flag when Chart1DblClick (2) triggled,and clear the flag.
But the flag is set again by (3).. so if I doubleclicked the TChart after (3), it result in that TAxisArrowTool was doubleclicked..
Is there any better idea?

Code: Select all

TAxisArrowToolClick      (1)
Chart1DblClick              (2)
TAxisArrowToolClick      (3)
Thanks in advance.

Re: Is there a OnMarkClick() event?

Posted: Mon Jun 16, 2014 11:18 am
by yeray
Hello,
elmec wrote:And one more question about TAxisArrowTool.
I want to know if TChart or TAxisArrowTool is doubleclicked.
I've done a simple tests, and adding a boolean variable as follows I seem to be able to check when the arrow has been doubleclicked:

Code: Select all

var dbClick: bool=false;

procedure TForm1.Chart1Click(Sender: TObject);
begin
  dbClick:=false;
  Memo1.Lines.Add('Chart Click');
end;

procedure TForm1.Chart1DblClick(Sender: TObject);
begin
  dbClick:=true;
  Memo1.Lines.Add('Chart DblClick');
end;

procedure TForm1.ChartTool1Click(Sender: TAxisArrowTool; AtStart: Boolean);
begin
  if dbClick then
  begin
    Memo1.Lines.Add('Arrow DblClick');
    dbClick:=false;
  end
  else
    Memo1.Lines.Add('Arrow Click');
end;
This sounds as a completely different question. Please, try to create different threads for different questions as indicated in the instructions in my signature.

Re: Is there a OnMarkClick() event?

Posted: Tue Jun 17, 2014 2:29 am
by 16566869
Thank you.

But I also want to do sth.
when just doubleclicking the TChart, not the TAxisArrowTool,
so I want to know which is doubleclicked when TChartDblClicked event triggled.

Re: Is there a OnMarkClick() event?

Posted: Tue Jun 17, 2014 2:32 am
by 16566869
In a word, I want to do sth. as below in Chart1DblClick function.

Code: Select all

void __fastcall TForm12::Chart1DblClick(TObject *Sender)
{
	if (AxisArrowClicked)
		do sth.
	else
		do sth.
}

Re: Is there a OnMarkClick() event?

Posted: Tue Jun 17, 2014 1:04 pm
by yeray
Hello,

You can play further with the events to find what you are looking for.
If I understand you correctly, this would achieve it:

Code: Select all

var chartClicked: bool=false;
    chartDblClicked: bool=false;
    arrowClicked: bool=false;
    arrowDblClicked: bool=false;
    myMouseDown: TPoint;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.Pages.MaxPointsPerPage:=5;
end;

procedure TForm1.Chart1Click(Sender: TObject);
begin
  chartDblClicked:=false;
  arrowDblClicked:=false;
  chartClicked:=true;
end;

procedure TForm1.Chart1DblClick(Sender: TObject);
begin
  chartDblClicked:=true;
end;

procedure TForm1.ChartTool1Click(Sender: TAxisArrowTool; AtStart: Boolean);
begin
  if chartDblClicked then
  begin
    arrowDblClicked:=true;
    chartDblClicked:=false;
  end
  else
  begin
    arrowClicked:=true;
    chartClicked:=false;
  end;
end;

procedure TForm1.Chart1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  myMouseDown.X:=X;
  myMouseDown.Y:=Y;
end;

procedure TForm1.Chart1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  if chartClicked then
    Memo1.Lines.Add('Chart Clicked');
  if arrowClicked then
    Memo1.Lines.Add('Arrow Clicked');
  if chartDblClicked then
    Memo1.Lines.Add('Chart Double Clicked');
  if arrowDblClicked then
    Memo1.Lines.Add('Arrow Double Clicked');

  chartClicked:=false;
  arrowClicked:=false;
  chartDblClicked:=false;
  arrowDblClicked:=false;
end;