Board index » delphi » Traversing TEdits with the Enter key?

Traversing TEdits with the Enter key?

I would like to traverse my Tedit fields using the Enter key and not the
Tab key, can someone explain how to do this.  I set the OnKeyPressed
event to true and ?

if Key = #13 then ?

Shane Holmes

 

Re:Traversing TEdits with the Enter key?


In article <4kkgha$...@mercury.IntNet.net>,
   holme...@netsrq.com (Shane Holmes) wrote:

Quote
>I would like to traverse my Tedit fields using the Enter key and not the
>Tab key, can someone explain how to do this.  I set the OnKeyPressed
>event to true and ?

>if Key = #13 then ?

>Shane Holmes

Here's a pretty simple way to go about that:

  if Key=#13 then
  begin
    (Sender as TWinControl).SelectNext(True,True);
    Key := #0;
  end;

The first parameter of SelectNext is GoForward (if you want to be weird and
make ENTER go backwards through your fields, set it to False ;)

The second one is CheckTabStops.  Set it to False if you want to stop at all
the controls, instead of jumping between groups of controls.

  --=- Ritchie A.

Re:Traversing TEdits with the Enter key?


On 15 Apr 1996 09:07:05 GMT, t...@netway.ab.ca (Ritchie Annand) wrote:

Quote
>>I would like to traverse my Tedit fields using the Enter key and not the
>>Tab key, can someone explain how to do this.  I set the OnKeyPressed
>>event to true and ?

Can someone tell me how to disable the irritating sound you get
everytime you press the enter key inside a TEdit ?

Thanks.

.-"-.,.-"-.,.-"-.,.-"-.,.-"-.,.-"-.,.-"-.,.-"-.,.-"-.

              Email : ch...@cytec.pl.my
 http://www.geopages.com/Sunsetstrip/2098/index.html

.-"-.,.-"-.,.-"-.,.-"-.,.-"-.,.-"-.,.-"-.,.-"-.,.-"-.

Re:Traversing TEdits with the Enter key?


Quote
>> On 15 Apr 1996 09:07:05 GMT, t...@netway.ab.ca (Ritchie Annand)

wrote:

Quote
>>I would like to traverse my Tedit fields using the Enter key and not
the
>>Tab key, can someone explain how to do this.  I set the OnKeyPressed
>>event to true and ? <<

This is simple - you will have just one default button, called say
OkButton, and you create the following code for its 'OnClick'. If the
OkButton is not focused, focus passes to the next component in the Tab
Order than can accept focus.

procedure TForm.OkButtonClick(Sender : TObject);
begin
  { Only allow Ok if the OkButton is focused, else convert action to
'Tab' }
  if not OkButton.Focused then begin
    Perform(wm_NextDlgCtl, 0, 0);
    ModalResult := mrNone;
    Exit;
    end;
end;

dick Glover

Other Threads