DateTimePicker - don't call OnChange when undoing changes

git-svn-id: trunk@54652 -
This commit is contained in:
zoran 2017-04-20 13:00:35 +00:00
parent 71e9ef32c4
commit 1ed8c064f8

View File

@ -186,11 +186,11 @@ type
FConfirmedDateTime: TDateTime; FConfirmedDateTime: TDateTime;
FNoEditingDone: Integer; FNoEditingDone: Integer;
FAllowDroppingCalendar: Boolean; FAllowDroppingCalendar: Boolean;
FChangeInRecursiveCall: Boolean;
FCorrectedDTP: TDateTimePart; FCorrectedDTP: TDateTimePart;
FCorrectedValue: Word; FCorrectedValue: Word;
FEnableWhenUnchecked: Boolean; FEnableWhenUnchecked: Boolean;
FAutoCheck: Boolean; FAutoCheck: Boolean;
FSkipChangeInUpdateDate: Integer;
function AreSeparatorsStored: Boolean; function AreSeparatorsStored: Boolean;
function GetChecked: Boolean; function GetChecked: Boolean;
@ -1922,11 +1922,13 @@ end;
procedure TCustomDateTimePicker.UndoChanges; procedure TCustomDateTimePicker.UndoChanges;
begin begin
if (FDateTime <> FConfirmedDateTime) then FDateTime := FConfirmedDateTime;
begin Inc(FSkipChangeInUpdateDate);
FDateTime := FConfirmedDateTime; try
UpdateDate; UpdateDate;
end; finally
Dec(FSkipChangeInUpdateDate);
end;
end; end;
{ GetDateTimePartFromTextPart function { GetDateTimePartFromTextPart function
@ -2764,9 +2766,10 @@ begin
FDateTime := ComposeDateTime(FMinDate, FDateTime); FDateTime := ComposeDateTime(FMinDate, FDateTime);
end; end;
if not FChangeInRecursiveCall then begin // we'll skip the next part in if (FSkipChangeInUpdateDate = 0) then begin
// recursive calls which could be made through Change or UndoChanges // we'll skip the next part if called from UndoChanges
FChangeInRecursiveCall := True; // and in recursive calls which could be made through calling Change
Inc(FSkipChangeInUpdateDate);
try try
if FUserChanging > 0 then begin // this means that the change is caused by user interaction if FUserChanging > 0 then begin // this means that the change is caused by user interaction
try try
@ -2778,7 +2781,7 @@ begin
end else end else
FConfirmedDateTime := FDateTime; FConfirmedDateTime := FDateTime;
finally finally
FChangeInRecursiveCall := False; Dec(FSkipChangeInUpdateDate);
end; end;
end; end;
@ -3807,7 +3810,7 @@ begin
FCalAlignment := dtaDefault; FCalAlignment := dtaDefault;
FCorrectedDTP := dtpAMPM; FCorrectedDTP := dtpAMPM;
FCorrectedValue := 0; FCorrectedValue := 0;
FChangeInRecursiveCall := False; FSkipChangeInUpdateDate := 0;
FNoEditingDone := 0; FNoEditingDone := 0;
FArrowShape := asTheme; FArrowShape := asTheme;
FAllowDroppingCalendar := True; FAllowDroppingCalendar := True;