mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-25 05:37:17 +01:00
lcl: enter in Edit state before item is changed in TDB*ListBox
git-svn-id: trunk@32503 -
This commit is contained in:
parent
7c1c1c2e3e
commit
230dedbde2
@ -350,6 +350,7 @@ Type
|
||||
procedure UpdateData(Sender: TObject); virtual;
|
||||
// we need to override the Items Write method for db aware.
|
||||
procedure SetItems(Values : TStrings); override;
|
||||
procedure WMLButtonDown(var Message: TLMLButtonDown); message LM_LBUTTONDOWN;
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
|
||||
@ -60,6 +60,12 @@ begin
|
||||
DataChange(Self);
|
||||
end;
|
||||
|
||||
procedure TCustomDBListBox.WMLButtonDown(var Message: TLMLButtonDown);
|
||||
begin
|
||||
FDataLink.Edit;
|
||||
inherited;
|
||||
end;
|
||||
|
||||
//we want to override the readonly state so we can
|
||||
//reflect the state of the Datalink/Field
|
||||
function TCustomDBListBox.GetReadOnly: Boolean;
|
||||
@ -99,10 +105,17 @@ end;
|
||||
procedure TCustomDBListBox.KeyDown(var Key: Word; Shift: TShiftState);
|
||||
begin
|
||||
inherited KeyDown(Key,Shift);
|
||||
if Key=VK_ESCAPE then begin
|
||||
//cancel out of editing by reset on esc
|
||||
FDataLink.Reset;
|
||||
Key := VK_UNKNOWN;
|
||||
case Key of
|
||||
VK_ESCAPE:
|
||||
begin
|
||||
//cancel out of editing by reset on esc
|
||||
FDataLink.Reset;
|
||||
Key := VK_UNKNOWN;
|
||||
end;
|
||||
VK_DOWN, VK_UP:
|
||||
begin
|
||||
FDataLink.Edit;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
@ -39,20 +39,7 @@ end;
|
||||
procedure TDBListBox.DoSelectionChange(User: Boolean);
|
||||
begin
|
||||
if User then
|
||||
begin
|
||||
//make sure we are in modify mode if can edit
|
||||
//so if a user changed the selection it can be
|
||||
//updated, and if not cancel out ala ReadOnly
|
||||
if FDataLink.Edit then
|
||||
FDataLink.Modified
|
||||
else
|
||||
begin
|
||||
// restore value
|
||||
DataChange(Self);
|
||||
//necessary to avoid double call of SelectionChange
|
||||
Exit;
|
||||
end;
|
||||
end;
|
||||
FDataLink.Modified;
|
||||
inherited DoSelectionChange(User);
|
||||
end;
|
||||
|
||||
|
||||
@ -62,21 +62,8 @@ procedure TDBLookupListBox.DoSelectionChange(User: Boolean);
|
||||
begin
|
||||
if User then
|
||||
begin
|
||||
//make sure we are in modify mode if can edit
|
||||
//so if a user changed the selection it can be
|
||||
//updated, and if not cancel out ala ReadOnly
|
||||
if FDataLink.Edit then
|
||||
begin
|
||||
FDataLink.Modified;
|
||||
FDataLink.UpdateRecord;
|
||||
end
|
||||
else
|
||||
begin
|
||||
// restore value
|
||||
DataChange(Self);
|
||||
//necessary to avoid double call of SelectionChange
|
||||
Exit;
|
||||
end;
|
||||
FDataLink.Modified;
|
||||
FDataLink.UpdateRecord;
|
||||
end;
|
||||
inherited DoSelectionChange(User);
|
||||
end;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user