Page 1 of 1
Double Click bug
Posted: Thu Mar 19, 2009 12:51 am
by 10051902
Hi,
I have a chart with a cursor tool (followmouse is true).
I use the double click chart event to zoom sections of the chart depending where the cursor is (in my case the chart is zoomed when the cursor/mouse is in a colorband). The problem is that the cursor is in 'selection' mode after the double click event, but only if the chart was zoomed during the double click handler.
Posted: Thu Mar 19, 2009 10:07 am
by yeray
Hi strobbekoen,
I think that you should use a custom zoom. Something as follows:
Code: Select all
var
Form1: TForm1;
DrawRect: Boolean;
XStart, XEnd, YStart, YEnd: Integer;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
XStart := -1;
XEnd := -1;
YStart := -1;
YEnd := -1;
DrawRect := false;
Chart1.Zoom.Allow := false;
end;
procedure TForm1.Chart1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var ZoomRect: TRect;
begin
If DrawRect then
begin
DrawRect := false;
ZoomRect.Left := XStart;
ZoomRect.Top := YStart;
ZoomRect.Right := XEnd;
ZoomRect.Bottom := YEnd;
Chart1.ZoomRect(ZoomRect);
end;
end;
procedure TForm1.Chart1AfterDraw(Sender: TObject);
begin
if DrawRect then
begin
Chart1.Canvas.Pen.Color := clWhite;
Chart1.Canvas.Brush.Style := bsClear;
Chart1.Canvas.Rectangle(XStart,YStart,XEnd,YEnd);
end;
end;
procedure TForm1.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if DrawRect then
begin
XEnd := X;
YEnd := Y;
Chart1.Draw;
end
else
begin
XStart := X;
YStart := Y;
end;
end;
procedure TForm1.Chart1DblClick(Sender: TObject);
begin
DrawRect := True;
end;
Also, let me suggest you to consider another possibility. You could use mousewheel to zoom the chart as described
here.
Posted: Thu Mar 19, 2009 2:33 pm
by 10051902
Thanks for the tip