From 592bea80e8db6f1a9b1bc9066b51e8ad8db5c6e1 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Wed, 4 Jul 2018 22:02:34 +0000 Subject: [PATCH] callite: Fix click selecting incorrect day if mouse is moved during the timer interval. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6544 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/callite/source/calendarlite.pas | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/components/callite/source/calendarlite.pas b/components/callite/source/calendarlite.pas index 2834f1705..1488f05ba 100644 --- a/components/callite/source/calendarlite.pas +++ b/components/callite/source/calendarlite.pas @@ -199,7 +199,7 @@ type procedure GotoMonth(AMonth: word); procedure GotoToday; procedure GotoYear(AYear: word); - procedure LeftClick(Shift: TShiftState); + procedure LeftClick(APoint: TPoint; Shift: TShiftState); procedure RightClick; public constructor Create(ACanvas: TCanvas); @@ -1192,16 +1192,15 @@ begin FOwner.Date := d; end; -procedure TCalDrawer.LeftClick(Shift: TShiftState); +procedure TCalDrawer.LeftClick(APoint: TPoint; Shift: TShiftState); var - p, ppopup: TPoint; + ppopup: TPoint; cell: TSize; Rm, Ry: TRect; sm: TCalSelMode; begin sm := FOwner.SelMode(Shift); - p := FOwner.ScreenToClient(Mouse.CursorPos); - cell := GetCellAt(p); + cell := GetCellAt(APoint); case cell.cy of TopRow: case cell.cx of @@ -1210,12 +1209,12 @@ begin 3..5: begin GetMonthYearRects(Rm{%H-}, Ry{%H-}); - if PtInRect(Rm, p) then begin + if PtInRect(Rm, APoint) then begin FOwner.PopulateMonthPopupMenu; ppopup := FOwner.ClientToScreen(Point(Rm.Left, Rm.Bottom)); FOwner.FPopupMenu.PopUp(ppopup.x, ppopup.y); end; - if PtInRect(Ry, p) then begin + if PtInRect(Ry, APoint) then begin FOwner.PopulateYearPopupMenu; ppopup := FOwner.ClientToScreen(Point(Ry.Left, Ry.Bottom)); FOwner.FPopupMenu.Popup(ppopup.x, ppopup.y); @@ -1432,7 +1431,7 @@ begin FDblClickTimer.Enabled := false; inherited; case FClickButton of - mbLeft : FCalDrawer.LeftClick(FClickShift + [ssDouble]); + mbLeft : FCalDrawer.LeftClick(FClickPoint, FClickShift + [ssDouble]); mbRight : ; end; end; @@ -1485,7 +1484,7 @@ end; procedure TCalendarLite.InternalClick; begin case FClickButton of - mbLeft : FCalDrawer.LeftClick(FClickShift); + mbLeft : FCalDrawer.LeftClick(FClickPoint, FClickShift); mbRight : FCalDrawer.RightClick; end; end;