Recent

Author Topic: TEdit, have Enter key perform Tab action?  (Read 7806 times)

RichardAD

  • Newbie
  • Posts: 2
TEdit, have Enter key perform Tab action?
« on: February 20, 2009, 04:40:33 pm »
In windows a simple OnKeyPress handler can cause the tab to occur.

procedure TForm1.MyEditKeyPress(Sender: TObject; var Key: char);
begin
  if Key = Chr(VK_RETURN) then
    PostMessage(Self.Handle,WM_KEYDOWN,VK_TAB,0)
end;

My concern is for non-window platforms... I'm guessing WM_KEYDOWN is not handled the same across all platforms.  Is there a OS-neutral approach to having Enter cause the next control in the tab sequence to be entered?

Bart

  • Hero Member
  • *****
  • Posts: 3546
    • Bart en Mariska's Webstek
Re: TEdit, have Enter key perform Tab action?
« Reply #1 on: February 21, 2009, 06:28:39 pm »
This might be what you want?
Code: [Select]
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: char);
begin
  if (Key = #13) then
  begin
    SelectNext(Sender as TWinControl, True, True);
    Key := #0;
  end;
end;

(SelectNext is a method of TForm)

Bart