Hello Papafrank and Derek,
Derek I hope you don't mind, but I'd like to offer a minor difference to your code, which in its' present state no longer keeps the edit box on return from form 2, so of course doesn't quite do what Papafrank wants, but could be useful for someone else.
1. Click on the Form1 adn enable the property 'Key Preview'
2. Double Click on the Form1 event OnKeyPress and add below code to the script
procedure Form1_OnKeyPress (Sender: TObject; var Key: Char);
begin
if Key = #13 then
begin
twincontrol(form1.findcomponent(vwherefrom)).setfocus;
Key :=#0;
end;
end;
3. Amend the Form1_EditXX_OnEnter code to:
Procedure Form1_Edit1_OnEnter (Sender: TObject);
begin
vwherefrom := Form1.Edit2.Name; //'edit1';
resetcolors;
form1.edit1.Color := $00C0DCC1;
end;
Do that to all the 'OnEnter' code and then you also not only have the edit boxes change colour when you click in them but you can now move from edit box to edit box just by pressing the Enter key.
The advantage to changing vwherefrom := 'EditXX' to vWhereFrom := Form1.EditXX.Name is that if you change the EditBox name at anytime you won't have to change the script. It also allows for some cut and paste into other programs.
Note that each edit box vWhereFrom := Form1.EditXX.Name 'points to the next edit box , not the current one
I tried to see if there was a way to have 'intelligent code' which would recognise which edit box had been entered and automatically move to the next edit box but I couldn't get
if form1.Controls[i] is TEdit
or
if form1.components[i] is TEdit
to work.
On a clear disk you can seek forever