View Issue Details

IDProjectCategoryView StatusLast Update
0030600LazarusPatchpublic2016-11-07 08:18
ReporterPascal RiekenbergAssigned ToMartin Friebe 
PrioritynormalSeverityminorReproducibilityN/A
Status closedResolutionfixed 
Product Version1.7 (SVN)Product Build 
Target Version1.8Fixed in Version1.7 (SVN) 
Summary0030600: BeforeKeyUpHandler for TCustomSynEdit
DescriptionAdded RegisterBeforeKeyUpHandler and UnregisterBeforeKeyUpHandler in preparation of more universal TSynEditMarkupCtrlMouseLink.
TagsNo tags attached.
Fixed in Revision52985
LazTarget1.8
Widgetset
Attached Files
  • synedit.pp_BeforeKeyUpHandler.patch (3,220 bytes)
    Index: synedit.pp
    ===================================================================
    --- synedit.pp	(revision 52969)
    +++ synedit.pp	(working copy)
    @@ -393,6 +393,13 @@
         procedure CallKeyDownHandlers(Sender: TObject; var Key: Word; Shift: TShiftState);
       end;
     
    +  { TLazSynKeyUpEventList }
    +
    +  TLazSynKeyUpEventList = Class(TMethodList)
    +  public
    +    procedure CallKeyUpHandlers(Sender: TObject; var Key: Word; Shift: TShiftState);
    +  end;
    +
       { TLazSynKeyPressEventList }
     
       TLazSynKeyPressEventList = Class(TMethodList)
    @@ -555,6 +562,7 @@
         FUndoRedoItemHandlerList: TSynUndoRedoItemHandlerList;
         FMouseDownEventList: TLazSynMouseDownEventList;
         FKeyDownEventList: TLazSynKeyDownEventList;
    +    FKeyUpEventList: TLazSynKeyUpEventList;
         FKeyPressEventList: TLazSynKeyPressEventList;
         FUtf8KeyPressEventList: TLazSynUtf8KeyPressEventList;
         FStatusChangedList: TObject;
    @@ -1044,6 +1058,8 @@
     
         procedure RegisterBeforeKeyDownHandler(AHandlerProc: TKeyEvent);
         procedure UnregisterBeforeKeyDownHandler(AHandlerProc: TKeyEvent);
    +    procedure RegisterBeforeKeyUpHandler(AHandlerProc: TKeyEvent);
    +    procedure UnregisterBeforeKeyUpHandler(AHandlerProc: TKeyEvent);
         procedure RegisterBeforeKeyPressHandler(AHandlerProc: TKeyPressEvent);
         procedure UnregisterBeforeKeyPressHandler(AHandlerProc: TKeyPressEvent);
         procedure RegisterBeforeUtf8KeyPressHandler(AHandlerProc: TUTF8KeyPressEvent);
    @@ -1438,6 +1454,18 @@
         constructor Create(AEvent: THookedCommandEvent; AData: pointer; AFlags: THookedCommandFlags);
       end;
     
    +{ TLazSynKeyUpEventList }
    +
    +procedure TLazSynKeyUpEventList.CallKeyUpHandlers(Sender: TObject;
    +  var Key: Word; Shift: TShiftState);
    +var
    +  i: LongInt;
    +begin
    +  i:=Count;
    +  while NextDownIndex(i) do
    +    TKeyEvent(Items[i])(Sender, Key, Shift);
    +end;
    +
     { TSynEditUndoCaret }
     
     function TSynEditUndoCaret.IsEqualContent(AnItem: TSynEditUndoItem): Boolean;
    @@ -2495,6 +2523,7 @@
       FBeautifier := nil;
       FreeAndNil(FDefaultBeautifier);
       FreeAndNil(FKeyDownEventList);
    +  FreeAndNil(FKeyUpEventList);
       FreeAndNil(FMouseDownEventList);
       FreeAndNil(FKeyPressEventList);
       FreeAndNil(FUtf8KeyPressEventList);
    @@ -2902,6 +2931,12 @@
       DebugLn(['[TCustomSynEdit.KeyUp] ',Key
         ,' Shift=',ssShift in Shift,' Ctrl=',ssCtrl in Shift,' Alt=',ssAlt in Shift]);
       {$ENDIF}
    +
    +  // Run even before OnKeyUp
    +  if FKeyUpEventList <> nil then
    +    FKeyUpEventList.CallKeyUpHandlers(Self, Key, Shift);
    +  if Key=0 then exit;
    +
       inherited KeyUp(Key, Shift);
     
       if sfIgnoreNextChar in fStateFlags then
    @@ -9185,6 +9246,19 @@
         FKeyDownEventList.Remove(TMethod(AHandlerProc));
     end;
     
    +procedure TCustomSynEdit.RegisterBeforeKeyUpHandler(AHandlerProc: TKeyEvent);
    +begin
    +  if FKeyUpEventList = nil then
    +    FKeyUpEventList := TLazSynKeyUpEventList.Create;
    +  FKeyUpEventList.Add(TMethod(AHandlerProc));
    +end;
    +
    +procedure TCustomSynEdit.UnregisterBeforeKeyUpHandler(AHandlerProc: TKeyEvent);
    +begin
    +  if FKeyUpEventList <> nil then
    +    FKeyUpEventList.Remove(TMethod(AHandlerProc));
    +end;
    +
     procedure TCustomSynEdit.RegisterBeforeKeyPressHandler(AHandlerProc: TKeyPressEvent);
     begin
       if FKeyPressEventList = nil then
    

Activities

Pascal Riekenberg

2016-09-14 13:06

reporter  

synedit.pp_BeforeKeyUpHandler.patch (3,220 bytes)
Index: synedit.pp
===================================================================
--- synedit.pp	(revision 52969)
+++ synedit.pp	(working copy)
@@ -393,6 +393,13 @@
     procedure CallKeyDownHandlers(Sender: TObject; var Key: Word; Shift: TShiftState);
   end;
 
+  { TLazSynKeyUpEventList }
+
+  TLazSynKeyUpEventList = Class(TMethodList)
+  public
+    procedure CallKeyUpHandlers(Sender: TObject; var Key: Word; Shift: TShiftState);
+  end;
+
   { TLazSynKeyPressEventList }
 
   TLazSynKeyPressEventList = Class(TMethodList)
@@ -555,6 +562,7 @@
     FUndoRedoItemHandlerList: TSynUndoRedoItemHandlerList;
     FMouseDownEventList: TLazSynMouseDownEventList;
     FKeyDownEventList: TLazSynKeyDownEventList;
+    FKeyUpEventList: TLazSynKeyUpEventList;
     FKeyPressEventList: TLazSynKeyPressEventList;
     FUtf8KeyPressEventList: TLazSynUtf8KeyPressEventList;
     FStatusChangedList: TObject;
@@ -1044,6 +1058,8 @@
 
     procedure RegisterBeforeKeyDownHandler(AHandlerProc: TKeyEvent);
     procedure UnregisterBeforeKeyDownHandler(AHandlerProc: TKeyEvent);
+    procedure RegisterBeforeKeyUpHandler(AHandlerProc: TKeyEvent);
+    procedure UnregisterBeforeKeyUpHandler(AHandlerProc: TKeyEvent);
     procedure RegisterBeforeKeyPressHandler(AHandlerProc: TKeyPressEvent);
     procedure UnregisterBeforeKeyPressHandler(AHandlerProc: TKeyPressEvent);
     procedure RegisterBeforeUtf8KeyPressHandler(AHandlerProc: TUTF8KeyPressEvent);
@@ -1438,6 +1454,18 @@
     constructor Create(AEvent: THookedCommandEvent; AData: pointer; AFlags: THookedCommandFlags);
   end;
 
+{ TLazSynKeyUpEventList }
+
+procedure TLazSynKeyUpEventList.CallKeyUpHandlers(Sender: TObject;
+  var Key: Word; Shift: TShiftState);
+var
+  i: LongInt;
+begin
+  i:=Count;
+  while NextDownIndex(i) do
+    TKeyEvent(Items[i])(Sender, Key, Shift);
+end;
+
 { TSynEditUndoCaret }
 
 function TSynEditUndoCaret.IsEqualContent(AnItem: TSynEditUndoItem): Boolean;
@@ -2495,6 +2523,7 @@
   FBeautifier := nil;
   FreeAndNil(FDefaultBeautifier);
   FreeAndNil(FKeyDownEventList);
+  FreeAndNil(FKeyUpEventList);
   FreeAndNil(FMouseDownEventList);
   FreeAndNil(FKeyPressEventList);
   FreeAndNil(FUtf8KeyPressEventList);
@@ -2902,6 +2931,12 @@
   DebugLn(['[TCustomSynEdit.KeyUp] ',Key
     ,' Shift=',ssShift in Shift,' Ctrl=',ssCtrl in Shift,' Alt=',ssAlt in Shift]);
   {$ENDIF}
+
+  // Run even before OnKeyUp
+  if FKeyUpEventList <> nil then
+    FKeyUpEventList.CallKeyUpHandlers(Self, Key, Shift);
+  if Key=0 then exit;
+
   inherited KeyUp(Key, Shift);
 
   if sfIgnoreNextChar in fStateFlags then
@@ -9185,6 +9246,19 @@
     FKeyDownEventList.Remove(TMethod(AHandlerProc));
 end;
 
+procedure TCustomSynEdit.RegisterBeforeKeyUpHandler(AHandlerProc: TKeyEvent);
+begin
+  if FKeyUpEventList = nil then
+    FKeyUpEventList := TLazSynKeyUpEventList.Create;
+  FKeyUpEventList.Add(TMethod(AHandlerProc));
+end;
+
+procedure TCustomSynEdit.UnregisterBeforeKeyUpHandler(AHandlerProc: TKeyEvent);
+begin
+  if FKeyUpEventList <> nil then
+    FKeyUpEventList.Remove(TMethod(AHandlerProc));
+end;
+
 procedure TCustomSynEdit.RegisterBeforeKeyPressHandler(AHandlerProc: TKeyPressEvent);
 begin
   if FKeyPressEventList = nil then

Martin Friebe

2016-09-18 01:05

manager   ~0094701

applied

did not need a new class, keydown handler class has same signature (would have renamed to more generic, but it is in interface part)

Issue History

Date Modified Username Field Change
2016-09-14 13:06 Pascal Riekenberg New Issue
2016-09-14 13:06 Pascal Riekenberg File Added: synedit.pp_BeforeKeyUpHandler.patch
2016-09-14 16:01 Martin Friebe Assigned To => Martin Friebe
2016-09-14 16:01 Martin Friebe Status new => assigned
2016-09-18 01:05 Martin Friebe Fixed in Revision => 52985
2016-09-18 01:05 Martin Friebe LazTarget => 1.8
2016-09-18 01:05 Martin Friebe Note Added: 0094701
2016-09-18 01:05 Martin Friebe Status assigned => resolved
2016-09-18 01:05 Martin Friebe Fixed in Version => 1.7 (SVN)
2016-09-18 01:05 Martin Friebe Resolution open => fixed
2016-09-18 01:05 Martin Friebe Target Version => 1.8
2016-11-07 08:18 Pascal Riekenberg Status resolved => closed