View Issue Details

IDProjectCategoryView StatusLast Update
0026769LazarusLCLpublic2014-09-25 08:33
ReporterBigChimpAssigned ToZeljan Rikalo 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Platformx64 (with x86 compiler)OSWindowsOS VersionWindows 7
Product Version1.3 (SVN)Product Build46305 
Target Version1.2.6Fixed in Version1.3 (SVN) 
Summary0026769: TMemo calls OnEditingDone when pressing Enter
DescriptionWhen editing text in a TMemo, pressing enter (e.g. to go to a new line), OnEditingDone is called.

See example program.

IMO this is not expected as the user is still editing inside the control.

Tagsevent, patch
Fixed in Revision46320
LazTarget1.2.6
WidgetsetWin32/Win64
Attached Files
  • memo_oneditingdone.zip (64,833 bytes)
  • custommemo.inc.patch (774 bytes)
    Index: custommemo.inc
    ===================================================================
    --- custommemo.inc	(revision 46308)
    +++ custommemo.inc	(working copy)
    @@ -203,6 +203,17 @@
     end;
     
     {------------------------------------------------------------------------------
    +  Prevents false firing of the OnEditingDone event if the memo accepts the
    +  RETURN key for new-line input.
    + ------------------------------------------------------------------------------}
    +procedure TCustomMemo.KeyUpAfterInterface(var Key: Word; Shift: TShiftState);
    +begin
    +  if (Key = VK_RETURN) and FWantReturns then
    +    Key := 0;
    +  inherited;
    +end;
    +
    +{------------------------------------------------------------------------------
       Method: TCustomMemo.SetLines
       Params: 
       Returns: 
    
    custommemo.inc.patch (774 bytes)
  • custommemo-v2.patch (1,398 bytes)
    Index: include/custommemo.inc
    ===================================================================
    --- include/custommemo.inc	(revision 46308)
    +++ include/custommemo.inc	(working copy)
    @@ -203,6 +203,17 @@
     end;
     
     {------------------------------------------------------------------------------
    +  Prevents false firing of the OnEditingDone event if the memo accepts the
    +  RETURN key for new-line input.
    + ------------------------------------------------------------------------------}
    +procedure TCustomMemo.KeyUpAfterInterface(var Key: Word; Shift: TShiftState);
    +begin
    +  if (Key = VK_RETURN) and FWantReturns then
    +    Key := 0;
    +  inherited;
    +end;
    +
    +{------------------------------------------------------------------------------
       Method: TCustomMemo.SetLines
       Params: 
       Returns: 
    Index: stdctrls.pp
    ===================================================================
    --- stdctrls.pp	(revision 46308)
    +++ stdctrls.pp	(working copy)
    @@ -816,6 +816,7 @@
         procedure RealSetText(const Value: TCaption); override;
         function GetCachedText(var CachedText: TCaption): boolean; override;
         function GetCaretPos: TPoint; override;
    +    procedure KeyUpAfterInterface(var Key: Word; Shift: TShiftState); override;
         procedure SetCaretPos(const Value: TPoint); override;
         procedure SetLines(const Value: TStrings);
         procedure SetSelText(const Val: string); override;
    
    custommemo-v2.patch (1,398 bytes)

Activities

Reinier Olislagers

2014-09-24 10:35

developer  

memo_oneditingdone.zip (64,833 bytes)

wp

2014-09-24 17:32

developer  

custommemo.inc.patch (774 bytes)
Index: custommemo.inc
===================================================================
--- custommemo.inc	(revision 46308)
+++ custommemo.inc	(working copy)
@@ -203,6 +203,17 @@
 end;
 
 {------------------------------------------------------------------------------
+  Prevents false firing of the OnEditingDone event if the memo accepts the
+  RETURN key for new-line input.
+ ------------------------------------------------------------------------------}
+procedure TCustomMemo.KeyUpAfterInterface(var Key: Word; Shift: TShiftState);
+begin
+  if (Key = VK_RETURN) and FWantReturns then
+    Key := 0;
+  inherited;
+end;
+
+{------------------------------------------------------------------------------
   Method: TCustomMemo.SetLines
   Params: 
   Returns: 
custommemo.inc.patch (774 bytes)

wp

2014-09-24 17:33

developer   ~0077593

The attached patch seems to fix the issue, at least for Windows (other environments not tested)

wp

2014-09-24 17:43

developer  

custommemo-v2.patch (1,398 bytes)
Index: include/custommemo.inc
===================================================================
--- include/custommemo.inc	(revision 46308)
+++ include/custommemo.inc	(working copy)
@@ -203,6 +203,17 @@
 end;
 
 {------------------------------------------------------------------------------
+  Prevents false firing of the OnEditingDone event if the memo accepts the
+  RETURN key for new-line input.
+ ------------------------------------------------------------------------------}
+procedure TCustomMemo.KeyUpAfterInterface(var Key: Word; Shift: TShiftState);
+begin
+  if (Key = VK_RETURN) and FWantReturns then
+    Key := 0;
+  inherited;
+end;
+
+{------------------------------------------------------------------------------
   Method: TCustomMemo.SetLines
   Params: 
   Returns: 
Index: stdctrls.pp
===================================================================
--- stdctrls.pp	(revision 46308)
+++ stdctrls.pp	(working copy)
@@ -816,6 +816,7 @@
     procedure RealSetText(const Value: TCaption); override;
     function GetCachedText(var CachedText: TCaption): boolean; override;
     function GetCaretPos: TPoint; override;
+    procedure KeyUpAfterInterface(var Key: Word; Shift: TShiftState); override;
     procedure SetCaretPos(const Value: TPoint); override;
     procedure SetLines(const Value: TStrings);
     procedure SetSelText(const Val: string); override;
custommemo-v2.patch (1,398 bytes)

wp

2014-09-24 17:46

developer   ~0077595

Sorry - forgot to include the declaration in the stdctrl unit... "custommemo-v2.patch" should work.

Reinier Olislagers

2014-09-24 18:13

developer   ~0077597

Problem reproducible on Linux x64 GTK2; confirmed patch works there.

Zeljan Rikalo

2014-09-25 08:19

developer   ~0077627

Please test and close if ok.

Reinier Olislagers

2014-09-25 08:33

developer   ~0077628

Thanks all!

Issue History

Date Modified Username Field Change
2014-09-24 10:35 Reinier Olislagers New Issue
2014-09-24 10:35 Reinier Olislagers File Added: memo_oneditingdone.zip
2014-09-24 11:37 Reinier Olislagers Tag Attached: event
2014-09-24 17:32 wp File Added: custommemo.inc.patch
2014-09-24 17:33 wp Note Added: 0077593
2014-09-24 17:43 wp File Added: custommemo-v2.patch
2014-09-24 17:44 Reinier Olislagers Tag Attached: patch
2014-09-24 17:46 wp Note Added: 0077595
2014-09-24 18:13 Reinier Olislagers Note Added: 0077597
2014-09-25 08:19 Zeljan Rikalo Fixed in Revision => 46320
2014-09-25 08:19 Zeljan Rikalo LazTarget - => 1.2.6
2014-09-25 08:19 Zeljan Rikalo Note Added: 0077627
2014-09-25 08:19 Zeljan Rikalo Status new => resolved
2014-09-25 08:19 Zeljan Rikalo Fixed in Version => 1.3 (SVN)
2014-09-25 08:19 Zeljan Rikalo Resolution open => fixed
2014-09-25 08:19 Zeljan Rikalo Assigned To => Zeljan Rikalo
2014-09-25 08:19 Zeljan Rikalo Target Version => 1.2.6
2014-09-25 08:33 Reinier Olislagers Note Added: 0077628
2014-09-25 08:33 Reinier Olislagers Status resolved => closed