Search code examples
delphifiremonkeydelphi-10.1-berlin

How to replace the removed Protected virtual DoTyping method from TCustomEdit?


I have a custom FMX combobox control I am trying to move from Delphi XE6 to Delphi 10.1 Berlin. The control inherits from TComboEdit. In my control, I override the protected virtual method - "DoTyping", that once existed in TCustomEdit, but no longer does in Delphi 10.1 Berlin. How do I keep my code without having to rewrite the entire control? Is there something synonymous in Delphi 10.1 Berlin that I am overseeing?

It looks as if TCustomEdit has added a new property

 Model: TCustomEditModel

Solution

  • This could not be easier.

    The stock TComboEdit has a OnTyping event.
    Wherever the DoTyping method has moved to it's a sure bet its implementation looks like this:

    procedure TSomething.DoTyping;
    begin
      if assigned(FOnTyping) then FOnTyping(Self);
    end;
    

    So just pick up the code that used to be in DoTyping, cut it.
    Put your custom ComboEdit (or a stock TComboEdit) on the form, go to events in the object inspector, double click on OnTyping and paste the code in the event handler.

    procedure TForm50.ComboEdit1Typing(Sender: TObject);
    begin
      //Paste here.
    end;
    

    This is what Uwe calls "wiring the event".