From 8ce29506c500e46d65b9a067bf446fd91224e6c0 Mon Sep 17 00:00:00 2001 From: bart <9132501-flyingsheep@users.noreply.gitlab.com> Date: Thu, 2 Feb 2017 11:33:18 +0000 Subject: [PATCH] TDateEdit: Don't change empty Text when toggling DirectInput in designer. Part of Issue #0030425. git-svn-id: trunk@54070 - --- lcl/editbtn.pas | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lcl/editbtn.pas b/lcl/editbtn.pas index 93486dce96..48175aecc3 100644 --- a/lcl/editbtn.pas +++ b/lcl/editbtn.pas @@ -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