RxCloseFormvalidate - add OnValidate event for item custom validate rule
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2761 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
fa1ffd579f
commit
eeb03913ca
@ -39,6 +39,9 @@ uses
|
||||
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, DB;
|
||||
|
||||
type
|
||||
TRxCloseFormValidator = class;
|
||||
|
||||
TValidateEvent = procedure(AOwner:TRxCloseFormValidator; AControl:TWinControl; var Validate:boolean) of object;
|
||||
|
||||
{ TValidateItem }
|
||||
|
||||
@ -47,6 +50,7 @@ type
|
||||
FControl: TWinControl;
|
||||
FEnabled: boolean;
|
||||
FFieldCaption: string;
|
||||
FOnValidate: TValidateEvent;
|
||||
procedure SetControl(AValue: TWinControl);
|
||||
procedure SetEnabled(AValue: boolean);
|
||||
procedure SetFieldCaption(AValue: string);
|
||||
@ -63,6 +67,7 @@ type
|
||||
property Control:TWinControl read FControl write SetControl;
|
||||
property Enabled:boolean read FEnabled write SetEnabled default true;
|
||||
property FieldCaption:string read FFieldCaption write SetFieldCaption;
|
||||
property OnValidate:TValidateEvent read FOnValidate write FOnValidate;
|
||||
end;
|
||||
|
||||
{ TValidateItems }
|
||||
@ -72,7 +77,6 @@ type
|
||||
function GetItems(Index: Integer): TValidateItem;
|
||||
procedure SetItems(Index: Integer; AValue: TValidateItem);
|
||||
public
|
||||
//constructor Create();
|
||||
property Items[Index: Integer]: TValidateItem read GetItems write SetItems; default;
|
||||
end;
|
||||
|
||||
@ -237,6 +241,11 @@ var
|
||||
begin
|
||||
Result:=true;
|
||||
if not Assigned(FControl) then exit;
|
||||
|
||||
if Assigned(FOnValidate) then
|
||||
FOnValidate( TRxCloseFormValidator(TValidateItems(Collection).Owner), FControl, Result)
|
||||
else
|
||||
begin
|
||||
if FControl = AForm.ActiveControl then
|
||||
begin
|
||||
AForm.SelectNext(FControl, true, true);
|
||||
@ -261,6 +270,7 @@ begin
|
||||
if Control is TCustomEdit then
|
||||
Result:=TCustomEdit(Control).Text<>'';
|
||||
end;
|
||||
end;
|
||||
|
||||
function TValidateItem.ErrorMessage: string;
|
||||
begin
|
||||
|
Loading…
Reference in New Issue
Block a user