Page 1 of 1

Make TCursorTool perform OnChange Event?

Posted: Tue Jan 23, 2007 1:09 pm
by 9242408
Is there a possible way to execute the OnChange event of the TCursor Tool from else where in my code?

I am updating labels showing the output this change and as doing the updat would like that event to execute WITHOUT actually moving a cursor.

Is this possible?


Thanks,


Tom

Posted: Tue Jan 23, 2007 1:47 pm
by narcis
Hi Tom,

Yes, you can do something like this:

Code: Select all

procedure TForm1.ChartTool1Change(Sender: TCursorTool; x, y: Integer;
  const XValue, YValue: Double; Series: TChartSeries; ValueIndex: Integer);
begin
  Chart1.Title.Text.Add('Cursor Changed');
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  if ((X0 <> -1) and (Y0 <> -1)) then
  begin
    ChartTool1Change(ChartTool1, X0, Y0, Chart1.Axes.Bottom.CalcPosPoint(X0),
                    Chart1.Axes.Bottom.CalcPosPoint(X0), ChartTool1.Series,
                    ChartTool1.Series.Clicked(X0,Y0));
  end;
end;

procedure TForm1.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  X0:=X;
  Y0:=Y;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  X0:=-1;
  Y0:=-1;
end;

Posted: Tue Jan 23, 2007 3:22 pm
by narcis
Hi Tom,

Sorry but the tool's event call should be something like this:

Code: Select all

    ChartTool1Change(ChartTool1, X0, Y0, Chart1.Axes.Bottom.CalcPosPoint(X0),
                    Chart1.Axes.Left.CalcPosPoint(Y0), ChartTool1.Series,
                    ChartTool1.Series.Clicked(X0,Y0));
I forgot to change the YValue argument after copy and paste :wink:.

Posted: Wed Jan 24, 2007 11:45 am
by 9242408
Thats ok, I got it working nice and smooth.


Thanks,

Tom