TDateEdit: Don't change empty Text when toggling DirectInput in designer. Part of Issue #0030425.

git-svn-id: trunk@54070 -
This commit is contained in:
bart 2017-02-02 11:33:18 +00:00
parent e5eb17948e
commit 8ce29506c5

View File

@ -569,6 +569,7 @@ type
procedure SetDirectInput(AValue: Boolean); override;
procedure RealSetText(const AValue: TCaption); override;
procedure SetDateMask; virtual;
procedure Loaded; override;
public
constructor Create(AOwner: TComponent); override;
function GetDateFormat: string;
@ -1653,9 +1654,11 @@ var
Def: TDateTime;
begin
inherited SetDirectInput(AValue);
//Synchronize FDate and force valid text
//Synchronize FDate
FDate := TextToDate(Text, NullDate);
SetDate(FDate);
//Force a valid date in the control, but not if Text was empty in designmode
if not ((csDesigning in ComponentState) and FDefaultToday and (FDate = NullDate)) then
SetDate(FDate);
end;
procedure TDateEdit.RealSetText(const AValue: TCaption);
@ -1709,6 +1712,14 @@ begin
SetDate(D);
end;
procedure TDateEdit.Loaded;
begin
inherited Loaded;
//Forces a valid Text in the control
if not (csDesigning in ComponentState) then
SetDate(FDate);
end;
Function ParseDate(S : String; Order : TDateOrder; Def: TDateTime) : TDateTime;
Var