View Issue Details

IDProjectCategoryView StatusLast Update
0027702LazarusLCLpublic2019-08-11 10:23
ReporterTony WhymanAssigned ToJuha Manninen 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionreopened 
PlatformAMD64OSLinux MintOS Version17
Product Version1.4RC2Product Build 
Target VersionFixed in Version 
Summary0027702: TDBDateEdit interferes with other Data Aware Controls
DescriptionThe problem can be seen on a form which has a TDBDateEdit and (e.g.) a TDBEdit with the same DataSource. The problem occurs when TDBDateEdit.AutoSelect is true.

Double click on the TDBEdit to select all. Now press any key. Instead of the edit box contents being replaced, the key value is appended to the end of the text - and the Date Edit text appears to be selected.

Now repeat again, but with TDBDateEdit.AutoSelect false. When the key is pressed, the edit box text is replaced i.e. the correct behaviour.

The problem appears to be in TDBDateEdit.AutoSelect where we find

if AutoSelect then SelectAll;

i.e. If AutoSelect is true then SelectAll is always called even when the control is not focused whenever a DataChange event occurs. This seems to be the root of the problem. The proposed fix (see patch) is to change this to

if Focused and AutoSelect then SelectAll;

i.e. SelectAll only called if the control is focussed.
TagsNo tags attached.
Fixed in Revisionr48504, r61681
LazTarget-
WidgetsetGTK 2
Attached Files
  • dbdateedit.patch (508 bytes)
    diff -rupN lazarus.rc2/lcl/include/dbdateedit.inc lazarus/lcl/include/dbdateedit.inc
    --- lazarus.rc2/lcl/include/dbdateedit.inc	2014-12-16 19:29:52.000000000 +0000
    +++ lazarus/lcl/include/dbdateedit.inc	2015-03-20 09:08:49.463173000 +0000
    @@ -14,7 +14,7 @@ procedure TDBDateEdit.DataChange(Sender:
     begin
       if FDataLink.Field <> nil then begin
          Self.Date := FDataLink.Field.AsDateTime;
    -     if AutoSelect then SelectAll;
    +     if Focused and AutoSelect then SelectAll;
       end
       else
         Text := '';
    
    dbdateedit.patch (508 bytes)
  • dbdateedit.inc.patch (533 bytes)
    Index: lcl/include/dbdateedit.inc
    ===================================================================
    --- lcl/include/dbdateedit.inc	(revision 61675)
    +++ lcl/include/dbdateedit.inc	(working copy)
    @@ -12,10 +12,8 @@
     
     procedure TDBDateEdit.DataChange(Sender: TObject);
     begin
    -  if FDataLink.Field <> nil then begin
    -     Self.Date := FDataLink.Field.AsDateTime;
    -     if Focused and AutoSelect then SelectAll;
    -  end
    +  if FDataLink.Field <> nil then
    +    Self.Date := FDataLink.Field.AsDateTime
       else
         Text := '';
     end;
    
    dbdateedit.inc.patch (533 bytes)

Activities

Tony Whyman

2015-03-20 12:06

reporter  

dbdateedit.patch (508 bytes)
diff -rupN lazarus.rc2/lcl/include/dbdateedit.inc lazarus/lcl/include/dbdateedit.inc
--- lazarus.rc2/lcl/include/dbdateedit.inc	2014-12-16 19:29:52.000000000 +0000
+++ lazarus/lcl/include/dbdateedit.inc	2015-03-20 09:08:49.463173000 +0000
@@ -14,7 +14,7 @@ procedure TDBDateEdit.DataChange(Sender:
 begin
   if FDataLink.Field <> nil then begin
      Self.Date := FDataLink.Field.AsDateTime;
-     if AutoSelect then SelectAll;
+     if Focused and AutoSelect then SelectAll;
   end
   else
     Text := '';
dbdateedit.patch (508 bytes)

LacaK

2015-03-20 22:01

developer   ~0082151

Or move:
  if AutoSelect then SelectAll;
into:
  procedure TDBDateEdit.EditEnter;
?

Or remove it ? I do not remember why it is there ?

Juha Manninen

2015-03-25 21:35

developer   ~0082312

I applied the patch, thanks. If there is a better fix then reopen and attach a new patch.

LacaK

2019-08-09 11:03

developer   ~0117610

Last edited: 2019-08-09 11:06

View 2 revisions

Sorry for so too late reopening, but optimization patch attached
(there is no need to handle AutoFocus specially, as it is handled for underlying TDateEdit)

LacaK

2019-08-09 11:04

developer  

dbdateedit.inc.patch (533 bytes)
Index: lcl/include/dbdateedit.inc
===================================================================
--- lcl/include/dbdateedit.inc	(revision 61675)
+++ lcl/include/dbdateedit.inc	(working copy)
@@ -12,10 +12,8 @@
 
 procedure TDBDateEdit.DataChange(Sender: TObject);
 begin
-  if FDataLink.Field <> nil then begin
-     Self.Date := FDataLink.Field.AsDateTime;
-     if Focused and AutoSelect then SelectAll;
-  end
+  if FDataLink.Field <> nil then
+    Self.Date := FDataLink.Field.AsDateTime
   else
     Text := '';
 end;
dbdateedit.inc.patch (533 bytes)

Juha Manninen

2019-08-11 10:23

developer   ~0117637

Applied the second patch. Thanks.

Issue History

Date Modified Username Field Change
2015-03-20 12:06 Tony Whyman New Issue
2015-03-20 12:06 Tony Whyman File Added: dbdateedit.patch
2015-03-20 22:01 LacaK Note Added: 0082151
2015-03-25 21:35 Juha Manninen Fixed in Revision => r48504
2015-03-25 21:35 Juha Manninen LazTarget => -
2015-03-25 21:35 Juha Manninen Note Added: 0082312
2015-03-25 21:35 Juha Manninen Status new => resolved
2015-03-25 21:35 Juha Manninen Resolution open => fixed
2015-03-25 21:35 Juha Manninen Assigned To => Juha Manninen
2019-08-09 11:03 LacaK Status resolved => assigned
2019-08-09 11:03 LacaK Resolution fixed => reopened
2019-08-09 11:03 LacaK Note Added: 0117610
2019-08-09 11:04 LacaK File Added: dbdateedit.inc.patch
2019-08-09 11:06 LacaK Note Edited: 0117610 View Revisions
2019-08-11 10:23 Juha Manninen Status assigned => resolved
2019-08-11 10:23 Juha Manninen Fixed in Revision r48504 => r48504, r61681
2019-08-11 10:23 Juha Manninen Widgetset GTK 2 => GTK 2
2019-08-11 10:23 Juha Manninen Note Added: 0117637