Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: How can XE6 FM change focus from one TEdit to another using <Return> key?


This question is answered.


Permlink Replies: 2 - Last Post: Sep 7, 2014 10:04 PM Last Post By: Iwan Cahyadi Su...
Jon Nevins

Posts: 12
Registered: 7/11/97
How can XE6 FM change focus from one TEdit to another using <Return> key?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 1, 2014 12:33 PM
In VCL using the shell I could check for a return key and go to the next Tab position. In FM I tried to SetFocus on the Next TEdit but this seems to disable it. How can I go to another TEdit using Tag order or SetFocus or whatever? In the Next TEdit the OnEnter event Enabled is True and ReadOnly and Locked are False, but there is no cursor and I can not type. OnEnter is activated however. I have KillFocusByReturn = True and ReturnKeyType=Next but these don't seem to matter.
Douglas Rudd

Posts: 314
Registered: 5/16/97
Re: How can XE6 FM change focus from one TEdit to another using <Return> key?
Correct
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 1, 2014 5:03 PM   in response to: Jon Nevins in response to: Jon Nevins
I don't know what you have done already, but I use this to use the return key to go to the next edit box:

Set the tag property of each editbox to some order.
Set the OnKeyUp event to the same handler for all the edit boxes.

Put this in the key up event:
procedure TForm6.Edit1KeyUp(Sender: TObject; var Key: Word; var KeyChar: Char; Shift: TShiftState);
begin
 if key=vkReturn then
  case TEdit(Sender).tag of
    0:
      Edit2.SetFocus;
    1:
      Edit3.SetFocus;
    2:
      Edit4.SetFocus;
    3:
      Edit1.SetFocus;
  end;
end;
Iwan Cahyadi Su...

Posts: 7
Registered: 10/5/06
Re: How can XE6 FM change focus from one TEdit to another using <Return> key?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 7, 2014 10:04 PM   in response to: Jon Nevins in response to: Jon Nevins
Got from another help (forgot where), you can try this code:

if Key = vkReturn then
begin
Key := vkTab;
KeyDown(Key,KeyChar,Shift);
end;

put it on the onKeyDown event handler

Jon Nevins wrote:
In VCL using the shell I could check for a return key and go to the next Tab position. In FM I tried to SetFocus on the Next TEdit but this seems to disable it. How can I go to another TEdit using Tag order or SetFocus or whatever? In the Next TEdit the OnEnter event Enabled is True and ReadOnly and Locked are False, but there is no cursor and I can not type. OnEnter is activated however. I have KillFocusByReturn = True and ReturnKeyType=Next but these don't seem to matter.
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02