I am using Delphi 6 Enterprise and TeeChart Pro 7.07.
We allow the user to perform customization options on the chart legend by intercepting a mouse click in the chart's OnClickLegend event. Overall, this works fine. Anytime the user clicks on the legend contents the event fires and we execute our code.
However, if the Legend Title is visible and the user clicks on the Title, the chart's OnClickLegend event does NOT fire. We would like the same logic to work for us whether the user clicks on the legend items, the legend background, or the legend title. Is there a way to make the OnClickLegend event recognize that the legend's title was clicked?
Thanks
Issue with OnClickLegend
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi rackerson,
Yes, you can achieve that using something like this:
Yes, you can achieve that using something like this:
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
begin
TitleClicked:=false;
end;
procedure TForm1.Chart1ClickLegend(Sender: TCustomChart;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if not TitleClicked then
Chart1.Title.Text.Add(IntToStr(Chart1.Legend.Clicked(X,Y)))
else
Chart1.Title.Text.Add('Legend title clicked');
end;
procedure TForm1.Chart1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if ((Chart1.Legend.Clicked(X,Y) = -1) and
(PtInRect(Chart1.Legend.RectLegend,Point(X,Y)))) then
begin
TitleClicked:=true;
Chart1ClickLegend(TCustomChart(Chart1),Button,Shift,X,Y);
end
else TitleClicked:=false;
end;
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |