mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-22 15:19:29 +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 SetReadOnly(const AValue: Boolean);
|
||||||
procedure CMGetDataLink(var Message: TLMessage); message CM_GETDATALINK;
|
procedure CMGetDataLink(var Message: TLMessage); message CM_GETDATALINK;
|
||||||
protected
|
protected
|
||||||
function DoEdit: boolean;
|
function DoEdit: boolean; virtual;
|
||||||
procedure DoOnCloseUp;
|
procedure DoOnCloseUp; virtual;
|
||||||
|
procedure DoOnSelect; virtual;
|
||||||
procedure LMDeferredEdit(var Message: TLMessage); message LM_DEFERREDEDIT;
|
procedure LMDeferredEdit(var Message: TLMessage); message LM_DEFERREDEDIT;
|
||||||
|
property DetectedEvents: Word read FDetectedEvents;
|
||||||
protected
|
protected
|
||||||
procedure CloseUp; override;
|
procedure CloseUp; override;
|
||||||
Procedure Select; override;
|
Procedure Select; override;
|
||||||
@ -831,6 +833,8 @@ Type
|
|||||||
{ TDBLookupComboBox }
|
{ TDBLookupComboBox }
|
||||||
|
|
||||||
TDBLookupComboBox = class(TCustomDBComboBox)
|
TDBLookupComboBox = class(TCustomDBComboBox)
|
||||||
|
protected
|
||||||
|
function DoEdit: boolean; override;
|
||||||
private
|
private
|
||||||
FLookup: TDBLookup;
|
FLookup: TDBLookup;
|
||||||
FScrollListDataset: Boolean;
|
FScrollListDataset: Boolean;
|
||||||
@ -851,7 +855,6 @@ Type
|
|||||||
procedure SetNullValueKey(const AValue: TShortCut);
|
procedure SetNullValueKey(const AValue: TShortCut);
|
||||||
procedure UpdateLookup;
|
procedure UpdateLookup;
|
||||||
protected
|
protected
|
||||||
procedure CloseUp; override;
|
|
||||||
procedure InitializeWnd; override;
|
procedure InitializeWnd; override;
|
||||||
procedure DestroyWnd; override;
|
procedure DestroyWnd; override;
|
||||||
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
|
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
|
||||||
@ -859,7 +862,6 @@ Type
|
|||||||
procedure Loaded; override;
|
procedure Loaded; override;
|
||||||
procedure UpdateData(Sender: TObject); override;
|
procedure UpdateData(Sender: TObject); override;
|
||||||
procedure DataChange(Sender: TObject); override;
|
procedure DataChange(Sender: TObject); override;
|
||||||
procedure Select; override;
|
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
property KeyValue: variant read GetKeyValue write SetKeyValue;
|
property KeyValue: variant read GetKeyValue write SetKeyValue;
|
||||||
@ -1855,6 +1857,11 @@ begin
|
|||||||
IsModified := False;
|
IsModified := False;
|
||||||
end;
|
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 dblookup.inc}
|
||||||
{$Include dbedit.inc}
|
{$Include dbedit.inc}
|
||||||
{$Include dbtext.inc}
|
{$Include dbtext.inc}
|
||||||
|
@ -15,11 +15,6 @@
|
|||||||
|
|
||||||
// included by dbctrls.pp
|
// included by dbctrls.pp
|
||||||
|
|
||||||
CONST
|
|
||||||
DBCBEVENT_CHANGE = 1; // Detected change event
|
|
||||||
DBCBEVENT_SELECT = 2; // Detected select event
|
|
||||||
DBCBEVENT_CLOSEUP = 4; // Detected closeup event
|
|
||||||
|
|
||||||
{TCustomDBComboBox}
|
{TCustomDBComboBox}
|
||||||
|
|
||||||
function TCustomDBComboBox.GetDataField: string;
|
function TCustomDBComboBox.GetDataField: string;
|
||||||
@ -77,7 +72,7 @@ begin
|
|||||||
if FDetectedEvents and DBCBEVENT_CHANGE <> 0 then
|
if FDetectedEvents and DBCBEVENT_CHANGE <> 0 then
|
||||||
inherited Change;
|
inherited Change;
|
||||||
if FDetectedEvents and DBCBEVENT_SELECT <> 0 then
|
if FDetectedEvents and DBCBEVENT_SELECT <> 0 then
|
||||||
inherited Select;
|
DoOnSelect;
|
||||||
end;
|
end;
|
||||||
if FDetectedEvents and DBCBEVENT_CLOSEUP <> 0 then
|
if FDetectedEvents and DBCBEVENT_CLOSEUP <> 0 then
|
||||||
DoOnCloseUp;
|
DoOnCloseUp;
|
||||||
@ -111,6 +106,11 @@ begin
|
|||||||
FDetectedEvents := 0; // reset because closeup may occur without editing
|
FDetectedEvents := 0; // reset because closeup may occur without editing
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomDBComboBox.DoOnSelect;
|
||||||
|
begin
|
||||||
|
inherited Select;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCustomDBComboBox.SetDataField(const AValue: string);
|
procedure TCustomDBComboBox.SetDataField(const AValue: string);
|
||||||
begin
|
begin
|
||||||
FDataLink.FieldName:=AValue;
|
FDataLink.FieldName:=AValue;
|
||||||
|
@ -38,6 +38,20 @@ begin
|
|||||||
Text := '';
|
Text := '';
|
||||||
end;
|
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);
|
procedure TDBLookupComboBox.ActiveChange(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
if FDataLink.Active then
|
if FDataLink.Active then
|
||||||
@ -45,16 +59,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TDBLookupComboBox.DataChange(Sender: TObject);
|
procedure TDBLookupComboBox.DataChange(Sender: TObject);
|
||||||
var
|
|
||||||
i: Integer;
|
|
||||||
begin
|
begin
|
||||||
if FDatalink.Active then
|
UpdateLookup;
|
||||||
i := FLookup.GetKeyIndex
|
|
||||||
else
|
|
||||||
i := -1;
|
|
||||||
ItemIndex := i;
|
|
||||||
if i = -1 then
|
|
||||||
Text := '';
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TDBLookupComboBox.DestroyWnd;
|
procedure TDBLookupComboBox.DestroyWnd;
|
||||||
@ -64,32 +70,6 @@ begin
|
|||||||
FLookup.ControlItems := Items;
|
FLookup.ControlItems := Items;
|
||||||
end;
|
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);
|
procedure TDBLookupComboBox.KeyDown(var Key: Word; Shift: TShiftState);
|
||||||
begin
|
begin
|
||||||
if FLookup.HandleNullKey(Key, Shift) then
|
if FLookup.HandleNullKey(Key, Shift) then
|
||||||
@ -210,10 +190,3 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TDBLookupComboBox.CloseUp;
|
|
||||||
begin
|
|
||||||
if Style = csDropDownList then
|
|
||||||
FDataLink.UpdateRecord;
|
|
||||||
inherited CloseUp;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user