try to fix fire event TRxDateEdit.OnAcceptDate whith CalendarStyle=csPopup - tnx ronin from freepascal.ru

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2276 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
alexs75
2012-02-03 21:52:00 +00:00
parent 00857e5d2c
commit 92a702ee40

View File

@ -93,7 +93,7 @@ type
procedure SetYearDigits(const AValue: TYearDigits); procedure SetYearDigits(const AValue: TYearDigits);
procedure CalendarHintsChanged(Sender: TObject); procedure CalendarHintsChanged(Sender: TObject);
// function AcceptPopup(var Value: Variant): Boolean; function AcceptPopup(var Value: TDateTime): Boolean;
procedure AcceptValue(const AValue: TDateTime); procedure AcceptValue(const AValue: TDateTime);
// procedure SetPopupValue(const Value: Variant); // procedure SetPopupValue(const Value: Variant);
protected protected
@ -217,7 +217,8 @@ function PaintComboEdit(Editor: TCustomMaskEdit; const AText: string;
function EditorTextMargins(Editor: TCustomMaskEdit): TPoint; function EditorTextMargins(Editor: TCustomMaskEdit): TPoint;
implementation implementation
uses lclintf, LCLStrConsts, rxconst, rxstrutils, LResources, Forms, LCLProc; uses lclintf, LCLStrConsts, rxconst, rxstrutils, LResources, Forms, LCLProc,
variants;
type type
TPopupCalendarAccess = class(TPopupCalendar) TPopupCalendarAccess = class(TPopupCalendar)
@ -509,23 +510,19 @@ begin
if not (csDesigning in ComponentState) then UpdatePopup; if not (csDesigning in ComponentState) then UpdatePopup;
end; end;
{function TCustomRxDateEdit.AcceptPopup(var Value: Variant): Boolean; function TCustomRxDateEdit.AcceptPopup(var Value: TDateTime): Boolean;
var var
D: TDateTime; D: TDateTime;
begin begin
Result := True; Result := True;
if Assigned(FOnAcceptDate) then begin if Assigned(FOnAcceptDate) then
if VarIsNull(Value) or VarIsEmpty(Value) then D := NullDate begin
else D :=Value;
try
D := VarToDateTime(Value);
except
if DefaultToday then D := SysUtils.Date else D := NullDate;
end;
FOnAcceptDate(Self, D, Result); FOnAcceptDate(Self, D, Result);
if Result then Value := VarFromDateTime(D); if Result then
Value := D;
end; end;
end;} end;
procedure TCustomRxDateEdit.AcceptValue(const AValue: TDateTime); procedure TCustomRxDateEdit.AcceptValue(const AValue: TDateTime);
begin begin
@ -667,6 +664,7 @@ end;
procedure TCustomRxDateEdit.ShowPopup(AOrigin: TPoint); procedure TCustomRxDateEdit.ShowPopup(AOrigin: TPoint);
var var
FAccept:boolean; FAccept:boolean;
D:TDateTime;
begin begin
if not Assigned(FPopup) then if not Assigned(FPopup) then
FPopup:=CreatePopupForm; FPopup:=CreatePopupForm;
@ -677,10 +675,15 @@ begin
FAccept:=FPopup.ShowModal = mrOk; FAccept:=FPopup.ShowModal = mrOk;
if CanFocus then SetFocus; if CanFocus then SetFocus;
if FAccept {and AcceptPopup(AValue) and EditCanModify }then if FAccept and EditCanModify then
begin begin
AcceptValue(FPopup.Date); D:=FPopup.Date;
if Focused then inherited SelectAll; if AcceptPopup(D) then
begin
FPopup.Date:=D;
AcceptValue(D);
if Focused then inherited SelectAll;
end;
end; end;
{ FPopup.Show(AOrigin); { FPopup.Show(AOrigin);