Hello, what is the right way to add a custom event handler to a TSynEdit ?
The following code results into an infinite loop (in AddGenericHandler()):
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, SynEdit,
SynMemo, SynEditTextBuffer, LazSynEditText;
type
TEditWithInternalChange = class(TSynMemo)
private
procedure internalChanged(Sender: TObject);
public
constructor Create(aOwner: TComponent); override;
end;
TForm1 = class(TForm)
private
ed: TEditWithInternalChange;
public
constructor Create(aOwner: TComponent); override;
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
constructor TEditWithInternalChange.Create(aOwner: TComponent);
begin
inherited;
TSynEditStringList(Lines).AddNotifyHandler(senrUndoRedoAdded, @internalChanged);
end;
procedure TEditWithInternalChange.internalChanged(Sender: TObject);
begin
end;
constructor TForm1.Create(aOwner: TComponent);
begin
inherited;
ed := TEditWithInternalChange.create(self);
ed.Parent := Self;
end;
end.
I suspect the "Lines" getter to be responsible of the problem (since the getter is actually a proxy function) but I'm not quite sure about that. Note that I cant use the public onChange event to overcome the issue because the event is used in the outside world.
I attached the small demo illustrating the bug.