mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-23 16:59:29 +01:00
Merged revision(s) 53938 #afa3922372 from trunk:
LCL: - Allow NullDate in TDateEdit when user clears the text. - Always set Text to a proper value when leaving the control. Issue #0031217 ........ git-svn-id: branches/fixes_1_6@53959 -
This commit is contained in:
parent
3ca7758d0f
commit
3b2ee9a030
@ -782,6 +782,7 @@ type
|
|||||||
function GetDefaultGlyphName: String; override;
|
function GetDefaultGlyphName: String; override;
|
||||||
procedure ButtonClick; override;
|
procedure ButtonClick; override;
|
||||||
procedure EditDblClick; override;
|
procedure EditDblClick; override;
|
||||||
|
procedure EditEditingDone; override;
|
||||||
procedure SetDirectInput(AValue: Boolean); override;
|
procedure SetDirectInput(AValue: Boolean); override;
|
||||||
procedure SetText(AValue: TCaption); override;
|
procedure SetText(AValue: TCaption); override;
|
||||||
procedure SetDateMask; virtual;
|
procedure SetDateMask; virtual;
|
||||||
@ -2553,6 +2554,19 @@ begin
|
|||||||
ButtonClick;
|
ButtonClick;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TDateEdit.EditEditingDone;
|
||||||
|
var
|
||||||
|
AText: String;
|
||||||
|
begin
|
||||||
|
inherited EditingDone;
|
||||||
|
if DirectInput then
|
||||||
|
begin
|
||||||
|
AText := DateToText(GetDate);
|
||||||
|
if AText <> Text then //avoid unneccesary recalculation FDate
|
||||||
|
Text := AText;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TDateEdit.SetDirectInput(AValue: Boolean);
|
procedure TDateEdit.SetDirectInput(AValue: Boolean);
|
||||||
var
|
var
|
||||||
Def: TDateTime;
|
Def: TDateTime;
|
||||||
@ -2888,10 +2902,20 @@ begin
|
|||||||
Def := FDate;
|
Def := FDate;
|
||||||
ADate := Trim(Text);
|
ADate := Trim(Text);
|
||||||
//if not DirectInput then FDate matches the Text, so no need to parse it
|
//if not DirectInput then FDate matches the Text, so no need to parse it
|
||||||
if (ADate <> '') and DirectInput then
|
if {(ADate <> '') and} DirectInput then
|
||||||
begin
|
begin
|
||||||
Result := TextToDate(ADate, Def);
|
if (ADate = '') then
|
||||||
FDate := Result;
|
begin
|
||||||
|
if FDefaultToday then
|
||||||
|
Result := SysUtils.Date
|
||||||
|
else
|
||||||
|
Result := NullDate;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
Result := TextToDate(ADate, Def);
|
||||||
|
FDate := Result;
|
||||||
|
end;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
Result := Def;
|
Result := Def;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user