TDateEdit and SelectNext(ActiveControl, False,True) lazarus / 31-LCL ---------------------------------------------------------------------- talorigomat · 2016-05-20 10:41 I use the following code in a  TEdit and TLabelledEdit OnExit event          Form1.SelectNext(ActiveControl, False,True) This has  the effect of the focus not moving to the next control but remaining on the current control when the tab key is pressed. The same code placed in a TDateEdit OnExit event doesn't have the same effect.  The focus moves to the next component when the tab key is pressed Is this a bug in Lazarus, or should I use another way to accomplish the same thing for TDateEdits? ---------------------------------------------------------------------- Bart · 2016-05-20 12:26 TDateEdit is an embedded control, it's parent is a TCustomControl. Look at the code that handles the Tab Key in the base class of TDateEdit how it is handled there, that may give you some clu how to solve this particular problem maybe. Alternatively can't you just intercept the Tab Key? Bart ---------------------------------------------------------------------- shacsoft · 2016-07-01 23:33 TDateEdit has their own "PerformTab" I found these solution: procedure TForm1.DateEdit1KeyDown(Sender: TObject; var Key: Word;   Shift: TShiftState); begin   if ((key=Vk_Up))  then begin     Key:=0;     DateEdit1.PerformTab(false);   end; end; ---------------------------------------------------------------------- u2o · 2017-09-17 03:23 Hi all! Apologies for writing here, but it can help anyone looking for a solution in the same place. I don't know if it is a bug, but to set focus forward, TWinControl.PerformTab(True); doesn't work. I've found one alternative... Need assign ControlsAll_OnEnter and ControlsAll_OnKeyDown to the controls events Quotevar     tLastFocused: TObject;  // <-- Save last TObject focused in the form // Private Variable procedure TForm1.ControlsAll_OnEnter(Sender: TObject); begin   if Sender.ClassType = TEdit then begin     tLastFocused := Sender;                                       // Register Last focused Object   end else if Sender.ClassType = TDateEdit then begin     tLastFocused := Sender;   end else if Sender.ClassType = TComboBox then begin     tLastFocused := Sender;   end else if Sender.ClassType = TMemo then begin     tLastFocused := Sender;   end else if Sender.ClassType = TBitBtn then begin     tLastFocused := Sender;   end else begin     // Disabled, only register some ClassType's   end; end; procedure TForm1.ControlsAll_OnKeyDown(Sender: TObject; var Key: word; Shift: TShiftState); var   cDateEdit: TDateEdit;   ctWinControl : tWinControl; begin   if (Shift = [ssAlt])  and ((key = VK_LEFT)) then begin                    // Setfocus to backward control     if tLastFocused.ClassType = TDateEdit then begin       cDateEdit := TDateEdit(tLastFocused);       cDateEdit.PerformTab(False);     end else begin       SelectNext(TWinControl(tLastFocused), False, True);     end;   end else if (Shift = [ssAlt]) and ((key = VK_RIGHT)) then begin      // Setfocus to forward control     if tLastFocused.ClassType = TDateEdit then begin       cDateEdit := TDateEdit(tLastFocused);       //cDateEdit.PerformTab(True);                                                  // <-- ¿Bug? // Don't work       ctWinControl := FindNextControl(cDateEdit, true, true, true);       //ShowMessage(ctWinControl .Name.ToUpper);       ctWinControl.SetFocus;     end else begin       SelectNext(TWinControl(tLastFocused), True, True);     end; end;