RichEditor : OnChange

Hello,



I try to catch change event each time the text changes in the RichEditor.



I used the OnChange event, but it isn't fired on TextChange.



How would I be able to vreate this kind of event ?



Regards



Christian

I'm not sure what you mean with "isn't fired on textchange".
When I drop this component on the form, attach the OnChange event and enter a key, the OnChange event is triggered here.

Thanks.



That's what I'd like to do.



I tested your code and it runs fine.



So I looked at mine :



I use RichEditor throught another class :



TMyMemo = class(TTMSFMXRichEditor)



And doing that, the event isn't fired, neither in the class itself, nor in the frame wich receives the TMyMemo created with :



          m_Memo := TMyMemo.Create(self);

          with m_Memo do

               begin

                    Parent := m_CurContainer;

                    Align := TAlignLayout.Top;

                    Size.Height := 400;



                    { TODO : ChangeEvent doesn't run }

                    OnChange := OnMemoChange;

               end;



procedure TInputInline.OnMemoChange(Sender: TObject);

     begin

          DataChange := true;

     end;

procedure OnMemoChange(Sender: TObject); //in public



Christian

I'm back again :



I've build a sample example which code is underneath.



The problame I have is taht the Change event is fired only once. So if the user inputs some new texts, I can't know when he did it.



I would like the Change event to be fired each time the text is changed.



Here is the code...

Regards



Christian



***first file



unit RichEditor;



interface



uses

     System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,

     FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,

     MyRichEditor, FMX.TMSRichEditor;



type

     TForm1 = class(TForm)

          procedure FormCreate(Sender: TObject);



     private

          { D?clarations priv?es }

          m_RichEditor: TMyRichEditor;

          m_OriginalRichEditor: TTMSFMXRichEditor;

     public

          { D?clarations publiques }

          procedure OnRichEditorChange(Sender: TObject);

          procedure OnOriginalRichEditorChange(Sender: TObject);

     end;



var

     Form1: TForm1;



implementation



{$R .fmx}



{ TForm1 }





procedure TForm1.FormCreate(Sender: TObject);

     begin

          Caption := '';



          m_RichEditor := TMyRichEditor.Create(self);

          with m_RichEditor do

               begin

                    Parent := self;

                    Align := TALignLayout.Top;

                    OnChange := OnRichEditorChange;

               end;



          m_OriginalRichEditor := TTMSFMXRichEditor.Create(self);

          with m_OriginalRichEditor do

               begin

                    Parent := self;

                    Align := TALignLayout.Bottom;

                    OnChange := OnOriginalRichEditorChange;

               end;

     end;





procedure TForm1.OnOriginalRichEditorChange(Sender: TObject);

     begin

          Caption := 'Original : ' + m_OriginalRichEditor.Text;

     end;





procedure TForm1.OnRichEditorChange(Sender: TObject);

     begin

          Caption := 'Herited : ' + m_RichEditor.Text;

     end;



end.



fmx file

object Form1: TForm1

Left = 0

Top = 0

Caption = 'Form1'

ClientHeight = 265

ClientWidth = 274

FormFactor.Width = 320

FormFactor.Height = 480

FormFactor.Devices = [Desktop]

OnCreate = FormCreate

DesignerMasterStyle = 0

end



******second file



unit MyRichEditor;// enforce UTF8 : пра



interface



uses

     System.SysUtils, System.Classes, FMX.Types, FMX.Controls,

     FMX.Controls.Presentation, FMX.StdCtrls, System.Types,

     FMX.TMSRichEditorToolBar, FMX.TMSToolBar, FMX.TMSBaseControl, UIConsts,

     FMX.TMSScrollControl, FMX.TMSRichEditorBase, FMX.TMSRichEditor, IOUtils,

     FMX.Layouts, FMX.TMSRichEditorMiniHTMLIO;



type

     TMyRichEditor = class(TTMSFMXRichEditor)



     private

          { D?clarations priv?es }

     protected

          { D?clarations prot?g?es }

     public

          { D?clarations publiques }

    constructor create(AOwner : TComponent); override;



     published

          { D?clarations publi?es }

     end;



implementation



{ TMyRichEditor }



{ TMyRichEditor }



constructor TMyRichEditor.create(AOwner: TComponent);

begin

inherited;

end;



end.



We have applied an improvement for the sometimes missing OnChange event. The next update will have this improvement.

Great.



Thanks a lot.



I do appreciate your will to help your customers.



Regards



Christian