TCursorTool Drags Outside Chart
TCursorTool Drags Outside Chart
I have vertical TCursorTool positioned near the left edge of a bottom axis. When I use the right mouse button to scroll the chart to the left, the cursor continues to be drawn, even after it leaves the edge of the chart. And even worse, if I continue to drag so that the cursor image makes it to the end of the window, I get an OnChange event telling me that the cursor has moved. It hasn't.
Re: TCursorTool Drags Outside Chart
Hi skassan,
I think that activating/deactivating the cursor at OnChartScroll event should solve this:
Note that this code would work if your cursor tool is the first tool and it is set as Vertical.
I think that activating/deactivating the cursor at OnChartScroll event should solve this:
Code: Select all
procedure TForm1.Chart1Scroll(Sender: TObject);
var CursorX: Integer;
begin
CursorX := Chart1.Axes.Bottom.CalcPosValue(ChartTool1.XValue);
if (CursorX >= Chart1.ChartRect.Left) and (CursorX <= Chart1.ChartRect.Right) then
ChartTool1.Active := true
else
ChartTool1.Active := false;
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: TCursorTool Drags Outside Chart
Thanks for the help. This works for scrolling, but using the same code for UndoZoom didn't work, for some reason. So I had to modify it as follows:
Code: Select all
void ClipCursorToChart(TCursorTool *Cursor)
{
TChartSeries *Series = Cursor->Series;
TCustomAxisPanel *Chart = Series->ParentChart;
TChartAxis *Axis = Chart->BottomAxis;
double CursorX = Cursor->XValue;
Cursor->Active = CursorX >= Axis->Minimum &&
CursorX <= Axis->Maximum;
}
Re: TCursorTool Drags Outside Chart
Hi skassan,
Thanks for the feedback. I'm happy to see that now it works as you expected.
Thanks for the feedback. I'm happy to see that now it works as you expected.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |