TAChart: Avoid chart popup menu opening at the end of a pan-drag operation with right mouse button.

git-svn-id: trunk@52391 -
This commit is contained in:
wp 2016-05-25 14:58:28 +00:00
parent 8999b027ad
commit c51bc87bab
2 changed files with 35 additions and 0 deletions

View File

@ -101,9 +101,11 @@ type
TBasicChartTool = class(TIndexedComponent)
strict protected
FChart: TChart;
FStartMousePos: TPoint;
procedure Activate; virtual;
procedure Deactivate; virtual;
function PopupMenuConflict: Boolean; virtual;
public
property Chart: TChart read FChart;
end;
@ -268,6 +270,8 @@ type
procedure VisitSources(
AVisitor: TChartOnSourceVisitor; AAxis: TChartAxis; var AData);
protected
FDisablePopupMenu: Boolean;
procedure DoContextPopup(MousePos: TPoint; var Handled: Boolean); override;
function DoMouseWheel(
AShift: TShiftState; AWheelDelta: Integer;
AMousePos: TPoint): Boolean; override;
@ -794,6 +798,12 @@ begin
AxisList.Draw(MaxInt, axisIndex);
end;
procedure TChart.DoContextPopup(MousePos: TPoint; var Handled: Boolean);
begin
if FDisablePopupMenu then Handled := true;
inherited;
end;
function TChart.DoMouseWheel(
AShift: TShiftState; AWheelDelta: Integer; AMousePos: TPoint): Boolean;
const
@ -1874,12 +1884,21 @@ procedure TBasicChartTool.Activate;
begin
FChart.FActiveToolIndex := Index;
FChart.MouseCapture := true;
FChart.FDisablePopupMenu := false;
FStartMousePos := Mouse.CursorPos;
end;
procedure TBasicChartTool.Deactivate;
begin
FChart.MouseCapture := false;
FChart.FActiveToolIndex := -1;
if PopupMenuConflict then
FChart.FDisablePopupMenu := true;
end;
function TBasicChartTool.PopupMenuConflict: Boolean;
begin
Result := false;
end;
procedure SkipObsoleteChartProperties;

View File

@ -69,6 +69,7 @@ type
procedure MouseUp(APoint: TPoint); virtual;
procedure MouseWheelDown(APoint: TPoint); virtual;
procedure MouseWheelUp(APoint: TPoint); virtual;
function PopupMenuConflict: Boolean; override;
procedure PrepareDrawingModePen(ADrawer: IChartDrawer; APen: TFPCustomPen);
procedure RestoreCursor;
procedure SetCursor;
@ -838,6 +839,21 @@ begin
Unused(APoint);
end;
function TChartTool.PopupMenuConflict: Boolean;
var
P: TPoint;
begin
Result := false;
if Shift = [ssRight] then begin
P := Mouse.CursorPos;
if (P.X = FStartMousePos.X) then
exit;
if (P.Y = FStartMousePos.Y) then
exit;
Result := true;
end;
end;
procedure TChartTool.PrepareDrawingModePen(
ADrawer: IChartDrawer; APen: TFPCustomPen);
begin