From e2af06f634cd266f786ab0c698eade959b189a4c Mon Sep 17 00:00:00 2001 From: wp Date: Fri, 29 Mar 2019 23:57:33 +0000 Subject: [PATCH] TAChart: Improved cooperation of TAxisClickTool with other tools. git-svn-id: trunk@60796 - --- components/tachart/tagraph.pas | 5 +---- components/tachart/tatools.pas | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/components/tachart/tagraph.pas b/components/tachart/tagraph.pas index 334e11081e..3d1d3d3436 100644 --- a/components/tachart/tagraph.pas +++ b/components/tachart/tagraph.pas @@ -1335,10 +1335,7 @@ var ts: TBasicChartToolset; begin ts := GetToolset; - if -// PtInRect(FClipRect, Point(X, Y)) and - (ts <> nil) and ts.Dispatch(Self, evidMouseDown, Shift, Point(X, Y)) - then + if (ts <> nil) and ts.Dispatch(Self, evidMouseDown, Shift, Point(X, Y)) then exit; inherited; end; diff --git a/components/tachart/tatools.pas b/components/tachart/tatools.pas index 931e339b9a..2a64982fc9 100644 --- a/components/tachart/tatools.pas +++ b/components/tachart/tatools.pas @@ -60,6 +60,7 @@ type property DrawingMode: TChartToolDrawingMode read FDrawingMode write SetDrawingMode default tdmDefault; strict protected + FIgnoreClipRect: Boolean; procedure Activate; override; procedure Cancel; virtual; procedure Deactivate; override; @@ -763,11 +764,12 @@ begin case AEventId of evidKeyDown : KeyDown (APoint); evidKeyUp : KeyUp (APoint); - evidMouseDown : MouseDown (APoint); - evidMouseMove : MouseMove (APoint); - evidMouseUp : MouseUp (APoint); evidMouseWheelDown: MouseWheelDown(APoint); evidMouseWheelUp : MouseWheelUp (APoint); + evidMouseMove : MouseMove (APoint); + evidMouseUp : MouseUp (APoint); + evidMouseDown : if FIgnoreClipRect or PtInRect(FChart.ClipRect, APoint) then + MouseDown(APoint); end; ev := FEventsAfter[AEventId]; if Assigned(ev) then @@ -2027,6 +2029,7 @@ constructor TAxisClickTool.Create(AOwner: TComponent); begin inherited Create(AOwner); SetPropDefaults(Self, ['GrabRadius']); + FIgnoreClipRect := true; // Allow mousedown outside cliprect end; function TAxisClickTool.GetHitTestInfo(APoint: TPoint): Boolean; @@ -2048,14 +2051,20 @@ end; procedure TAxisClickTool.MouseDown(APoint: TPoint); begin - if GetHitTestInfo(APoint) then + if GetHitTestInfo(APoint) then begin Activate; + Handled; + end; end; procedure TAxisClickTool.MouseUp(APoint: TPoint); begin - if FHitTest <> [] then + if FHitTest <> [] then begin + GetHitTestInfo(APoint); if Assigned(FOnClick) then FOnClick(Self, FAxis, FHitTest); + end; + Deactivate; + Handled; end;