How to select TEdit field text in Delphi 10

3

I have a very basic problem and I do not discover the cause ... I need the text from within a TEdit to be selected integer when the field receives focus. At the time of Delphi 7 with VCL I only made TEdit(Sender).SelLength := Length(TEdit(Sender).Text) in the OnEnter event. Now with Delphi 10.2 and FireMonkey I've tried it in several different ways, but it does not work.

Example:

procedure TfPrincipal.Edit1Enter(Sender: TObject);
begin
   TEdit(Sender).SetFocus;
   TEdit(Sender).SelStart  := 0; // Ja tentei mudar este valor
   TEdit(Sender).SelLength := Length(TEdit(Sender).Text); // Ja tentei mudar este valor também
end;

Does not Firemonkey work differently?

    
asked by anonymous 19.12.2017 / 21:19

1 answer

1

Another thing to set to SelLength a value greater than the number of characters from SelStart to results in the selection of all characters from SelStart to the end of the text.

TEdit(Sender).SetFocus ; 
TEdit(Sender).SelStart  : = 0; 
TEdit(Sender).SelLength := Length(TEdit(Sender).Text)+1;
    
21.12.2017 / 14:02