Delphi FMX set focus to a particular control so the cursor appears


I created a test new FMX project. Added a TabControl to it. Used the context menu to add 3 tabsheets. To the 3rd tabsheet, added a TEdit. Added a OnChangeEvent handler to the tabcontrol. Coded it as follows:

procedure TForm1.TabControl1Change(Sender: TObject);
if TabControl1.ActiveTab = TabItem3 then
self.ActiveControl := Edit1;
self.Focused := Edit1;

As you can see, I tried various combinations based on my previous VCL experience. The input/cursor focus does not change to the Edit1 by code. Of course, at runtime on Win32, if I click on the edit1, the focus rectangle (I’m using a style) now shows as does the cursor. (as expected) On Android. The VK only comes up when I shift the focus myself.

Is there way to do this programmatically so the user can just start typing? (without having to shift the focus to the TEdit themselves).

Comments are closed.