TTMSFNCTaskDialog : titCustom -> setFocus on Android


I have the following code:

  Var MyEdit : TTMSFNCEdit := TTMSFNCEdit.Create(TaskDialog);

  MyEdit.Parent            := TaskDialog;
  MyEdit.EditType          := etString; 
  MyEdit.Text              := 'something';
  MyEdit.Width             := 200;

  TaskDialog.InputType    := titCustom; // titEdit titDate titCustom titNone
  TaskDialog.InputControl := MyEdit;

    MyEdit.SetFocus; // either this
    MyEdit.SelectAll; // or this

In the code either I use MyEdit.SetFocus, or MyEdit.SelectAll (depending on a parameter).
The code work well on Windows, however MyEdit.SetFocus or MyEdit.SelectAll doesn't do anything on Android.
It is important because the user has to read barcodes continuously. With this behavior he needs to tap in the edit box and then read the barcode, which is quite frustrating when reading hundreds of a day :-).

Am I missing something? Thank you very much for your help.


TTMSFNCEdit is based on TEdit. In our tests TEdit.SelectAll alone was not selecting the text, but SetFocus was. Perhaps a combination of the two would do the trick.

With that being said, for TTMSFNCTaskDialog the mobile platforms use a popup instead of a form so that is probably what makes it different on Android.

Normally this should be resolved by doing SetFocus/SelectAll in the OnDiallogCreated event but that still seems too soon for Android as only the focus is given to the edit control and the selection is missing. A timer with 1 interval can do the trick here:

procedure TForm1.Timer1Timer(Sender: TObject);
  Timer1.Enabled := False;

procedure TForm1.TMSFNCTaskDialog1DialogCreated(Sender: TObject);
  Timer1.Enabled := True;

We'll look and discuss to potentially handle the timer for the event internally in the component but for now you'll need to do it manually.

Hello Tünde,

It works perfectly with the timer, thank you very much!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.