RxDBLookupCombo - new event OnChangeData

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3736 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
alexs75
2014-11-17 13:08:49 +00:00
parent a2359e13a8
commit 6deba80b9a

View File

@ -152,6 +152,7 @@ type
{ TRxCustomDBLookupCombo } { TRxCustomDBLookupCombo }
TRxCustomDBLookupCombo = class (TCustomControl) TRxCustomDBLookupCombo = class (TCustomControl)
private private
FOnChangeData: TNotifyEvent;
// //
FStopClick:boolean; FStopClick:boolean;
//FDataLink:TFieldDataLink; //FDataLink:TFieldDataLink;
@ -257,6 +258,7 @@ type
procedure DoSetBounds(ALeft, ATop, AWidth, AHeight: Integer); override; procedure DoSetBounds(ALeft, ATop, AWidth, AHeight: Integer); override;
procedure DoPositionButton; virtual; procedure DoPositionButton; virtual;
procedure DoChange; virtual; procedure DoChange; virtual;
procedure DoChangeData; virtual;
procedure DoButtonClick(Sender: TObject); virtual; procedure DoButtonClick(Sender: TObject); virtual;
Procedure Loaded; override; Procedure Loaded; override;
procedure Notification(AComponent: TComponent; Operation: TOperation); override; procedure Notification(AComponent: TComponent; Operation: TOperation); override;
@ -282,6 +284,7 @@ type
property NumGlyphs : Integer read GetNumGlyphs write SetNumGlyphs; property NumGlyphs : Integer read GetNumGlyphs write SetNumGlyphs;
property OnButtonClick : TNotifyEvent read FOnButtonClick write FOnButtonClick; property OnButtonClick : TNotifyEvent read FOnButtonClick write FOnButtonClick;
property OnChange : TNotifyEvent read FOnChange write FOnChange; property OnChange : TNotifyEvent read FOnChange write FOnChange;
property OnChangeData : TNotifyEvent read FOnChangeData write FOnChangeData;
property ReadOnly:boolean read FReadOnly write SetReadOnly; property ReadOnly:boolean read FReadOnly write SetReadOnly;
property EmptyValue: string read FEmptyValue write SetEmptyValue stored StoreEmpty; property EmptyValue: string read FEmptyValue write SetEmptyValue stored StoreEmpty;
property EmptyItemColor: TColor read FEmptyItemColor write SetEmptyItemColor default clWindow; property EmptyItemColor: TColor read FEmptyItemColor write SetEmptyItemColor default clWindow;
@ -342,6 +345,7 @@ type
property NumGlyphs; property NumGlyphs;
Property OnButtonClick; Property OnButtonClick;
property OnChange; property OnChange;
property OnChangeData;
property OnClick; property OnClick;
property OnClosePopup; property OnClosePopup;
property OnDblClick; property OnDblClick;
@ -1146,9 +1150,10 @@ end;
procedure TRxCustomDBLookupCombo.NeedUpdateData; procedure TRxCustomDBLookupCombo.NeedUpdateData;
begin begin
if FLookupDataLink.Active and Assigned(FDataField) then if FLookupDataLink.Active and Assigned(FDataField) then
begin ; begin
if FKeyField.IsNull then FDataField.Clear if FKeyField.IsNull then FDataField.Clear
else FDataField.AsString:=FKeyField.AsString else FDataField.AsString:=FKeyField.AsString;
DoChangeData;
end; end;
end; end;
@ -1259,6 +1264,7 @@ begin
UpdateKeyValue; UpdateKeyValue;
if Assigned(FOnSelect) then if Assigned(FOnSelect) then
FOnSelect(Self); FOnSelect(Self);
DoChangeData;
Key:=0; Key:=0;
end; end;
end; end;
@ -1299,8 +1305,8 @@ begin
FLookupDataLink.DataSet.Next; FLookupDataLink.DataSet.Next;
end; end;
SetValueKey(FKeyField.AsString); SetValueKey(FKeyField.AsString);
if Assigned(FOnSelect) then if Assigned(FOnSelect) then
FOnSelect(Self); FOnSelect(Self);
Key:=0; Key:=0;
end end
end; end;
@ -1351,6 +1357,12 @@ begin
FOnChange(Self); FOnChange(Self);
end; end;
procedure TRxCustomDBLookupCombo.DoChangeData;
begin
if Assigned(FOnChangeData) then
FOnChangeData(Self)
end;
procedure TRxCustomDBLookupCombo.DoButtonClick(Sender: TObject); procedure TRxCustomDBLookupCombo.DoButtonClick(Sender: TObject);
begin begin
if (not FReadOnly) and (not FStopClick) then//We can do something if and only if that's not ReadOnly field... if (not FReadOnly) and (not FStopClick) then//We can do something if and only if that's not ReadOnly field...
@ -1532,9 +1544,12 @@ begin
if (Value <> FValue) then if (Value <> FValue) then
begin begin
if FListActive and not ReadOnly and (FDataLink.DataSource <> nil) and FDataLink.Edit then if FListActive and not ReadOnly and (FDataLink.DataSource <> nil) and FDataLink.Edit then
FDataField.AsString := Value begin
FDataField.AsString := Value;
DoChangeData;
end
else else
SetValueKey(Value); SetValueKey(Value);
if Assigned(FOnSelect) then if Assigned(FOnSelect) then
FOnSelect(Self); FOnSelect(Self);
end; end;