View Issue Details

IDProjectCategoryView StatusLast Update
0027186LazarusLCLpublic2018-09-09 20:04
ReporterTony WhymanAssigned ToJesus Reyes 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version1.2.7 (SVN)Product Build 
Target Version1.10Fixed in Version1.9 (SVN) 
Summary0027186: TCustomDBComboBox descendents do not call "EditingDone" on CloseUp when style set to DropDownList
DescriptionWhen a TCustomDBComboBox descendent (e.g. TDBComboBox) style is set of DropDownList, and when the drop down list closes, the DataSet is not updated and hence the corresponding Field's OnChange event is not called.

This is different from the control's behaviour when the style is simply "DropDown" when the DataSet is updated and the corresponding Field's OnChange event is called.
Additional InformationThe problem seems to be due to the "ReadOnly" property being redefined by TCustomDBComboBox and having different semantics from TDBComboBox.ReadOnly.

TDBComboBox.CloseUp looks at its ReadOnly property and does not call EditingDone if it is true. ReadOnly is always set to true when the style is DropDownList.

However, the TCustomDBComboBox ReadOnly property is a different property and reflects whether the corresponding Field is or is not Read Only. It is also the property visible in the Object Inspector.


Because the CloseUp Method is called in the context of TDBComboBox, ReadOnly is always true for a DropDownList and hence EditingDone is not called and the dataset not updated.

The solution is simple enough. "CloseUp" is virtual and should be overridden by
TCustomDBComboBox so that EditingDone is called when its ReadOnly property is false.

See attached patch.
TagsNo tags attached.
Fixed in Revisionr56681,58686
LazTarget1.10
Widgetset
Attached Files
  • dbcombo.diff (1,267 bytes)
    diff -rupN -x '.*' devel/lcl/dbctrls.pp devel.modified/lcl/dbctrls.pp
    --- devel/lcl/dbctrls.pp	2014-12-05 08:53:57.243312240 +0000
    +++ devel.modified/lcl/dbctrls.pp	2014-12-19 11:42:50.543240812 +0000
    @@ -678,6 +678,7 @@ Type
         procedure SetReadOnly(const AValue: Boolean);
         procedure CMGetDataLink(var Message: TLMessage); message CM_GETDATALINK;
       protected
    +    procedure CloseUp; override;
         procedure DataChange(Sender: TObject); virtual; abstract;
         procedure Notification(AComponent: TComponent; Operation: TOperation); override;
         procedure Change; override;
    diff -rupN -x '.*' devel/lcl/include/customdbcombobox.inc devel.modified/lcl/include/customdbcombobox.inc
    --- devel/lcl/include/customdbcombobox.inc	2014-12-05 08:54:05.895270710 +0000
    +++ devel.modified/lcl/include/customdbcombobox.inc	2014-12-19 11:46:42.686687912 +0000
    @@ -64,6 +64,14 @@ begin
       Message.Result := PtrUInt(FDataLink);
     end;
     
    +procedure TCustomDBComboBox.CloseUp;
    +begin
    +  if [csLoading,csDestroying,csDesigning]*ComponentState<>[] then exit;
    +  if not ReadOnly then
    +    EditingDone;
    + inherited CloseUp;
    +end;
    +
     procedure TCustomDBComboBox.Notification(AComponent: TComponent; Operation: TOperation);
     begin
       inherited Notification(AComponent, Operation);
    
    dbcombo.diff (1,267 bytes)

Activities

Tony Whyman

2014-12-19 13:05

reporter  

dbcombo.diff (1,267 bytes)
diff -rupN -x '.*' devel/lcl/dbctrls.pp devel.modified/lcl/dbctrls.pp
--- devel/lcl/dbctrls.pp	2014-12-05 08:53:57.243312240 +0000
+++ devel.modified/lcl/dbctrls.pp	2014-12-19 11:42:50.543240812 +0000
@@ -678,6 +678,7 @@ Type
     procedure SetReadOnly(const AValue: Boolean);
     procedure CMGetDataLink(var Message: TLMessage); message CM_GETDATALINK;
   protected
+    procedure CloseUp; override;
     procedure DataChange(Sender: TObject); virtual; abstract;
     procedure Notification(AComponent: TComponent; Operation: TOperation); override;
     procedure Change; override;
diff -rupN -x '.*' devel/lcl/include/customdbcombobox.inc devel.modified/lcl/include/customdbcombobox.inc
--- devel/lcl/include/customdbcombobox.inc	2014-12-05 08:54:05.895270710 +0000
+++ devel.modified/lcl/include/customdbcombobox.inc	2014-12-19 11:46:42.686687912 +0000
@@ -64,6 +64,14 @@ begin
   Message.Result := PtrUInt(FDataLink);
 end;
 
+procedure TCustomDBComboBox.CloseUp;
+begin
+  if [csLoading,csDestroying,csDesigning]*ComponentState<>[] then exit;
+  if not ReadOnly then
+    EditingDone;
+ inherited CloseUp;
+end;
+
 procedure TCustomDBComboBox.Notification(AComponent: TComponent; Operation: TOperation);
 begin
   inherited Notification(AComponent, Operation);
dbcombo.diff (1,267 bytes)

Juha Manninen

2017-12-09 19:01

developer   ~0104613

Applied, thanks.
It was ignored for too long.

Jesus Reyes

2018-05-20 02:10

developer   ~0108443

I'm reviewing TDbCombobox and found your fix, it calls EditingDone in CloseUp, as EditingDone is used for moving the editor changes into the record I believe is an error because then ESCAPE key for dismissing the changes and restore the control text would not work anymore.

Jesus Reyes

2018-09-09 20:04

developer   ~0110600

CloseUp (or Selection to be precise) should affect only the current field and so the ESC key should be able to cancel the modification, with EditingDone the change is propagated to the record and canceling the record also cancels the probable changes in other fields which is an unwanted side effect.

In Lazarus we allow the combo box editing through mouse wheel and for this reason we have an incongruency here, we rely on the editingdone event in order to update the record but if the combo box is not focused the editingdone would not be triggered, in this case we allow updating the record on mouse wheel selection. This can be disabled by implementing the OnMouseWheel event and return true.

Issue History

Date Modified Username Field Change
2014-12-19 13:05 Tony Whyman New Issue
2014-12-19 13:05 Tony Whyman File Added: dbcombo.diff
2017-12-09 18:42 Juha Manninen Assigned To => Juha Manninen
2017-12-09 18:42 Juha Manninen Status new => assigned
2017-12-09 19:01 Juha Manninen Fixed in Revision => r56681
2017-12-09 19:01 Juha Manninen LazTarget => -
2017-12-09 19:01 Juha Manninen Note Added: 0104613
2017-12-09 19:01 Juha Manninen Status assigned => resolved
2017-12-09 19:01 Juha Manninen Resolution open => fixed
2018-05-20 01:36 Jesus Reyes Assigned To Juha Manninen => Jesus Reyes
2018-05-20 01:36 Jesus Reyes Status resolved => assigned
2018-05-20 02:10 Jesus Reyes Note Added: 0108443
2018-09-09 20:04 Jesus Reyes Fixed in Revision r56681 => r56681,58686
2018-09-09 20:04 Jesus Reyes LazTarget - => 1.10
2018-09-09 20:04 Jesus Reyes Note Added: 0110600
2018-09-09 20:04 Jesus Reyes Status assigned => resolved
2018-09-09 20:04 Jesus Reyes Fixed in Version => 1.9 (SVN)
2018-09-09 20:04 Jesus Reyes Target Version => 1.10