Is there a better way to auto-select next input form on [ENTER] ? lazarus / 1-Linux ---------------------------------------------------------------------- Mike J · 2009-11-22 23:21 Create blank form. Put 3 single line edit fields. Put an exit button, mark as 'default'. As created, pressing [ENTER] causes the program to exit, would be better if pressing [ENTER] moved to next input field. So... create event handler called EditKeyDown as follows. For all input fields, assign this same event handler to hand OnKeyDown event. Surely there is a better way to trigger focus to go to next tabstop in order! Code: [Select]procedure TForm1.EditKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState                );                                                                                        var                                                                                           maxStop: integer;                                                                         activeStop: integer;                                                                       x: integer;                                                                               EditField: TEdit;                                                                    begin                                                                                         if Key = VK_RETURN then begin                                                               Key := 0; //zap the return key                                                             //figure out highest tabstop number in case of wrap-around.                               for x := 0 to ComponentCount - 1 do begin                                                     if (Components[x].Classname='TEdit') {or (Components[x].Classname='TButton')} then           begin                                                                                              if (Components[x] as TEdit).TabOrder > maxStop then                                             maxStop := (Components[x] as TEdit).TabOrder;                                          if (Components[x] as TEdit).Focused then                                                     activeStop := (Components[x] as TEdit).TabOrder;                                 end;                                                                                   end;                                                                                       inc(activeStop);                                                                           for x := 0 to ComponentCount -1 do begin;                                                      if (Components[x].Classname='TEdit') {or (Components[x].Classname='TButton')} then           begin                                                                                           if (Components[x] as Tedit).TabOrder = activeStop then                                          (Components[x] as Tedit).SetFocus;                                                end;                                                                                 end;                                                                                       if activeStop > maxStop then ButtonExit.SetFocus;                                       end;                                                                                                                                                                              end; ---------------------------------------------------------------------- theo · 2009-11-23 09:10 Try this after setting the property "KeyPreview" of Form1 true; Code: [Select]procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState   ); begin   if Key = VK_RETURN then SelectNext(ActiveControl,true,true); end; ---------------------------------------------------------------------- Bart · 2009-11-23 10:40 Maybe check if Active control is indeed a TEdit? Code: [Select]procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState   ); begin   if (Key = VK_RETURN) and (AcitveControl is TEdit) then     SelectNext(ActiveControl,true,true); end; Bart ---------------------------------------------------------------------- Mike J · 2009-11-23 12:33 Quote from: theo on November 23, 2009, 10:10:53 amTry this after setting the property "KeyPreview" of Form1 true; Code: [Select]procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState   ); begin   if Key = VK_RETURN then SelectNext(ActiveControl,true,true); end; Thank you, that's the ticket.