Legend Checkbox left click not working, right click ok

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
darcy
Newbie
Newbie
Posts: 16
Joined: Mon Sep 14, 2009 12:00 am

Legend Checkbox left click not working, right click ok

Post by darcy » Mon Jan 25, 2010 3:36 pm

Folks,
For some reason my left click event in a Legend check box is no longer working. The right click and middle click works fine and triggers an OnClickLegend event successfully. I'm very confused as it was working previously. My legend position is drawn at a CustomPosition=true. I may be doing something stupid but please help.

Regards,
D'Arcy.

Yeray
Site Admin
Site Admin
Posts: 9602
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Legend Checkbox left click not working, right click ok

Post by Yeray » Mon Jan 25, 2010 4:24 pm

Hi D'Arcy,

I'm not able to reproduce it here with the following code:

Code: Select all

procedure TForm1.Chart1ClickLegend(Sender: TCustomChart; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  ShowMessage('legend clicked!');
end;

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  for i := 0 to 9 do
  begin
    Chart1.AddSeries(TLineSeries.Create(self));
    Chart1[i].FillSampleValues();
  end;

  Chart1.Legend.CheckBoxes:=true;
  Chart1.Legend.CustomPosition:=true;
  Chart1.Legend.Left:=100;
  Chart1.Legend.Top:=50;
end;
Could you please modify it so we can reproduce it here (or send us a simple example project we can run as-is to reproduce the problem here)?
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

darcy
Newbie
Newbie
Posts: 16
Joined: Mon Sep 14, 2009 12:00 am

Re: Legend Checkbox left click not working, right click ok

Post by darcy » Tue Jan 26, 2010 10:35 am

Hi Yeray,
Problem sorted. Thanks for the example. When I created a clean example the legend click worked fine (left, middle, right click). Therefore it was local to my application. One for your records, when the TDrawLineTool is added it can take control of the left click. Guess it was due to the left click and drag functionality being enabled by default within the tool which took precedence of the left click event. Only when I removed this did it re-enable the left click for the legend.

Thanks for the help.

Regards,
D'Arcy

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Legend Checkbox left click not working, right click ok

Post by Sandra » Tue Jan 26, 2010 1:16 pm

Hello darcy,

I found a simple solution that I think solve your problem. Please check next code works correctly.

Code: Select all

var ChartTool1: TDrawLineTool;
procedure TForm1.Chart1ClickLegend(Sender: TCustomChart; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  ShowMessage('legend clicked!');
end;

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  ChartTool1 := TDrawLineTool.Create(Self);
  Chart1.Tools.Add(ChartTool1) ;
  for i := 0 to 9 do
  begin
    Chart1.AddSeries(TLineSeries.Create(self));
    Chart1[i].FillSampleValues();
  end;
  Chart1.Legend.CheckBoxes:=true;
  Chart1.Legend.CustomPosition:=true;
  Chart1.Legend.Left:=100;
  Chart1.Legend.Top:=50;
end;

procedure TForm1.Chart1MouseDown(Sender: TObject; Button: TMouseButton;
 Shift: TShiftState; X, Y: Integer);
begin
  ChartTool1.EnableDraw:=not PtInRect(Chart1.Legend.RectLegend,Point(X,Y));
end;
I hope will help.

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply