Shifting the focus from one component to another in mobile using Delphi XE8

320 Views Asked by At

I'm developing Android mobile application using Delphi XE8 and please help me to do the following implementation.

In a Form, I'm having 3 Components which is the following order 1. TEdit (edtValue1), 2. TEdit (edtValue2), 3. TComboBox (cbxValue1)

When the form is opened I have made:

edtValue.SetFocus;

My doubt is after entering some values in edtValue1, then How can I shift the focus to edtValue2 by pressing the enter Key in the KeyPad in Android mobile. Also If I need to shift the focus to cbxValue1 after edtValue2, then How can I handle this also.? Please help me in this. Thanks in advance.

1

There are 1 best solutions below

0
On

Here is a code, which works for controls, you've mentioned:

procedure TForm1.FormCreate(Sender: TObject);
begin
  edtValue1.SetFocus;
end;

procedure TForm1.edtValue1KeyUp(Sender: TObject; var Key: Word; var KeyChar: Char;
  Shift: TShiftState);
begin
  if Key = 13 then
    edtValue2.SetFocus;
end;

procedure TForm1.edtValue2KeyUp(Sender: TObject; var Key: Word; var KeyChar: Char;
  Shift: TShiftState);
begin
  MouseDown(TMouseButton.mbLeft, [], cbxValue1.AbsoluteRect.CenterPoint.X, cbxValue1.AbsoluteRect.CenterPoint.Y);
end;

May be it is a bit cheaty, but it has good clues to explore.