From 09db53cc993b6a154e71b7a4285c6ac4ab6b9825 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Thu, 9 Jun 2022 20:48:10 +0000 Subject: [PATCH] TvPlanIt: Fix incorrect drag-and-drop operation to or within TVpMonthView (https://forum.lazarus.freepascal.org/index.php/topic,59578.0.html). git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8288 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/tvplanit/source/vpmonthview.pas | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/components/tvplanit/source/vpmonthview.pas b/components/tvplanit/source/vpmonthview.pas index fe79549f3..2dd47f7a2 100644 --- a/components/tvplanit/source/vpmonthview.pas +++ b/components/tvplanit/source/vpmonthview.pas @@ -698,7 +698,8 @@ var AllowIt: Boolean; EventDlg : TVpEventEditDialog; begin - if DataStore = nil then Exit; + if DataStore = nil then + Exit; if (not IsNewEvent) and (not mvActiveEvent.CanEdit) then begin MessageDlg(RSCannotEditOverlayedEvent, mtInformation, [mbOk], 0); @@ -718,7 +719,7 @@ begin EventDlg.Free; end; end; - + if AllowIt then begin mvActiveEvent.Changed := true; DataStore.PostEvents; @@ -732,7 +733,6 @@ begin DataStore.PostEvents; end; Invalidate; - mvActiveEvent := nil; end; procedure TVpMonthView.mvSpinButtonClick(Sender: TObject; Button: TUDBtnType); @@ -1061,6 +1061,8 @@ begin begin { The mouse click landed inside the client area } MvSetDateByCoord(Point(Msg.XPos, Msg.YPos)); + newEvent := not SelectEventAtCoord(Point(Msg.XPos, Msg.YPos)); + if newEvent then mvActiveEvent := nil; { Did the mouse click land on an event? } if Assigned(FOnEventDblClick) then begin @@ -1068,7 +1070,6 @@ begin FOnEventDblClick(self, mvActiveEvent); end else if mvActiveEvent <> nil then begin - newevent := not SelectEventAtCoord(Point(Msg.XPos, Msg.YPos)); mvSpawnEventEditDialog(newevent); end else if (DataStore.Resource <> nil) then begin @@ -1322,7 +1323,8 @@ var I: Integer; begin for I := 0 to pred(Length(mvMonthdayArray)) do - if PointInRect(APoint, mvMonthdayArray[I].Rec) then begin + if PointInRect(APoint, mvMonthdayArray[I].Rec) then + begin Date := mvMonthdayArray[I].Date; break; end;