mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-19 10:49:44 +02:00
LCL, fix unbound DbLookupCombobox regression caused by r58686 #8ff1532ca9, issue #33164
git-svn-id: trunk@58799 -
This commit is contained in:
parent
be4f5624f2
commit
6a5bc59a4d
@ -724,9 +724,11 @@ Type
|
||||
procedure SetReadOnly(const AValue: Boolean);
|
||||
procedure CMGetDataLink(var Message: TLMessage); message CM_GETDATALINK;
|
||||
protected
|
||||
function DoEdit: boolean;
|
||||
procedure DoOnCloseUp;
|
||||
function DoEdit: boolean; virtual;
|
||||
procedure DoOnCloseUp; virtual;
|
||||
procedure DoOnSelect; virtual;
|
||||
procedure LMDeferredEdit(var Message: TLMessage); message LM_DEFERREDEDIT;
|
||||
property DetectedEvents: Word read FDetectedEvents;
|
||||
protected
|
||||
procedure CloseUp; override;
|
||||
Procedure Select; override;
|
||||
@ -831,6 +833,8 @@ Type
|
||||
{ TDBLookupComboBox }
|
||||
|
||||
TDBLookupComboBox = class(TCustomDBComboBox)
|
||||
protected
|
||||
function DoEdit: boolean; override;
|
||||
private
|
||||
FLookup: TDBLookup;
|
||||
FScrollListDataset: Boolean;
|
||||
@ -851,7 +855,6 @@ Type
|
||||
procedure SetNullValueKey(const AValue: TShortCut);
|
||||
procedure UpdateLookup;
|
||||
protected
|
||||
procedure CloseUp; override;
|
||||
procedure InitializeWnd; override;
|
||||
procedure DestroyWnd; override;
|
||||
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
|
||||
@ -859,7 +862,6 @@ Type
|
||||
procedure Loaded; override;
|
||||
procedure UpdateData(Sender: TObject); override;
|
||||
procedure DataChange(Sender: TObject); override;
|
||||
procedure Select; override;
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
property KeyValue: variant read GetKeyValue write SetKeyValue;
|
||||
@ -1855,6 +1857,11 @@ begin
|
||||
IsModified := False;
|
||||
end;
|
||||
|
||||
CONST
|
||||
DBCBEVENT_CHANGE = 1; // CustomDBBoxCombobox Detected change event
|
||||
DBCBEVENT_SELECT = 2; // CustomDBBoxCombobox Detected select event
|
||||
DBCBEVENT_CLOSEUP = 4; // CustomDBBoxCombobox Detected closeup event
|
||||
|
||||
{$Include dblookup.inc}
|
||||
{$Include dbedit.inc}
|
||||
{$Include dbtext.inc}
|
||||
|
@ -15,11 +15,6 @@
|
||||
|
||||
// included by dbctrls.pp
|
||||
|
||||
CONST
|
||||
DBCBEVENT_CHANGE = 1; // Detected change event
|
||||
DBCBEVENT_SELECT = 2; // Detected select event
|
||||
DBCBEVENT_CLOSEUP = 4; // Detected closeup event
|
||||
|
||||
{TCustomDBComboBox}
|
||||
|
||||
function TCustomDBComboBox.GetDataField: string;
|
||||
@ -77,7 +72,7 @@ begin
|
||||
if FDetectedEvents and DBCBEVENT_CHANGE <> 0 then
|
||||
inherited Change;
|
||||
if FDetectedEvents and DBCBEVENT_SELECT <> 0 then
|
||||
inherited Select;
|
||||
DoOnSelect;
|
||||
end;
|
||||
if FDetectedEvents and DBCBEVENT_CLOSEUP <> 0 then
|
||||
DoOnCloseUp;
|
||||
@ -111,6 +106,11 @@ begin
|
||||
FDetectedEvents := 0; // reset because closeup may occur without editing
|
||||
end;
|
||||
|
||||
procedure TCustomDBComboBox.DoOnSelect;
|
||||
begin
|
||||
inherited Select;
|
||||
end;
|
||||
|
||||
procedure TCustomDBComboBox.SetDataField(const AValue: string);
|
||||
begin
|
||||
FDataLink.FieldName:=AValue;
|
||||
|
@ -38,6 +38,20 @@ begin
|
||||
Text := '';
|
||||
end;
|
||||
|
||||
function TDBLookupComboBox.DoEdit: boolean;
|
||||
begin
|
||||
if (FDataLink.DataSource=nil) or (DataField='') then begin
|
||||
if DetectedEvents and DBCBEVENT_SELECT <>0 then begin
|
||||
UpdateData(self);
|
||||
DoOnSelect;
|
||||
end;
|
||||
if DetectedEvents and DBCBEVENT_CLOSEUP <>0 then
|
||||
DoOnCloseUp;
|
||||
end
|
||||
else
|
||||
Result := inherited DoEdit;
|
||||
end;
|
||||
|
||||
procedure TDBLookupComboBox.ActiveChange(Sender: TObject);
|
||||
begin
|
||||
if FDataLink.Active then
|
||||
@ -45,16 +59,8 @@ begin
|
||||
end;
|
||||
|
||||
procedure TDBLookupComboBox.DataChange(Sender: TObject);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
if FDatalink.Active then
|
||||
i := FLookup.GetKeyIndex
|
||||
else
|
||||
i := -1;
|
||||
ItemIndex := i;
|
||||
if i = -1 then
|
||||
Text := '';
|
||||
UpdateLookup;
|
||||
end;
|
||||
|
||||
procedure TDBLookupComboBox.DestroyWnd;
|
||||
@ -64,32 +70,6 @@ begin
|
||||
FLookup.ControlItems := Items;
|
||||
end;
|
||||
|
||||
procedure TDBLookupComboBox.Select;
|
||||
begin
|
||||
FDataLink.OnDataChange := nil;
|
||||
try
|
||||
if FDataLink.Edit then
|
||||
begin
|
||||
FDataLink.Modified;
|
||||
FDataLink.UpdateData;
|
||||
inherited Select;
|
||||
end
|
||||
else
|
||||
begin
|
||||
// if cannot modify, let it reset
|
||||
if ReadOnly then begin
|
||||
FDatalink.Reset;
|
||||
DataChange(Self);
|
||||
end else begin
|
||||
FDataLink.Modified;
|
||||
inherited Select;
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
FDataLink.OnDataChange := @DataChange;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDBLookupComboBox.KeyDown(var Key: Word; Shift: TShiftState);
|
||||
begin
|
||||
if FLookup.HandleNullKey(Key, Shift) then
|
||||
@ -210,10 +190,3 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDBLookupComboBox.CloseUp;
|
||||
begin
|
||||
if Style = csDropDownList then
|
||||
FDataLink.UpdateRecord;
|
||||
inherited CloseUp;
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user