What's wrong with my code II / dynamically created checkboxes and Tabstop lazarus / 31-LCL ---------------------------------------------------------------------- hy · 2014-11-13 15:47 See the attached project. I am having a form (1) with checkboxes that have been inserted in the IDE. TAB-Movement works perfect. If you click on the button labelled "click me" another form (2) is opened. This form creates checkboxes and comboboxes dynamically (I don't know at compile time how much I will actually need - though the example is hardcoded). If you press TAB in the second form only the first  two controls are getting the focus. ---------------------------------------------------------------------- ChrisF · 2014-11-13 16:13 Not for me: Windows XP 32 bits, Lazarus 1.2.6. Anyway, as far I can see the "Taborder :=" is useless in your case (i.e. always set to the by-default value -1). It seems it's only taken in account after the Windows control is "really" created. So you could make a try by setting it after the "parent :=" instruction, like: Code: [Select]         parent := pnlMainOperate;          TabOrder := i *2 shl 1; ...          parent := pnlMainOperate;          TabOrder := i shl 1 + 1; ---------------------------------------------------------------------- ChrisF · 2014-11-13 16:18 Plus, your tabulation order computation is wrong (i.e. not the same) Code: [Select]TabOrder := i *2 shl 1;   and TabOrder := i shl 1 + 1; You should have: Code: [Select]TabOrder := i shl 1;   and TabOrder := i shl 1 + 1; ---------------------------------------------------------------------- hy · 2014-11-13 16:25 Thanks ChrisF. But If I change the order of inserting the control  (setting parent respectively) and setting TabOrder it doesn't alter the behaviour. The other thing you mentioned is a typo (resulting from downsizing the Problem to the relevant stuff). I fixed it, but it didn't change the erroneous behaviour. ---------------------------------------------------------------------- ChrisF · 2014-11-13 17:09 I can see in your signature that you are using a Linux OS. I guess this is probably why there is a difference between us (as I've written before, your code is working for me with Windows). You can eventually try to also set the TabStop option to true after the SetParent instruction. Though I'm not even sure that the controls are created for the Linux versions as for the Windows version (i.e. when the SetParent instruction is called). Curiously, you are saying that only the first 2 "dynamics" controls can be reached with the tabulation. And you have 2 "fixed" controls in your second form (i.e. 2 pushbuttons with tabulation order = 0 and 1). It may eventually be related. You could eventually add 2 other dummy pushbuttons, for instance, with tabulation order = 2 and 3, and see if the first 4 "dynamics" controls can now be reached with the tabulation. Just for a test purpose... ---------------------------------------------------------------------- hy · 2014-11-13 17:28 Hi ChrisF, that is very kind of you to be so creative though you can not reproduce the problem. But I am VERY sorry to have to tell you that it didn't work out. I changed the code to four dynamic items and four Buttons (also tried TEdit and others). What happens is: 1.) On startup of form2 the first dynamic item is focused correctly due to Code: [Select]activeControl := TCheckBox(self.pnlMainOperate.Controls[0]); 2.) Pressing focusses the (dynamically created) Combobox with Taborder:=2 [as everyone would expect] 3.) Pressing again focusses nothing 3.) Pressing again focusses the (dynamically created) Tcheckbox with Tab-Order = 0 Note: you can not reach the buttons via TAB at all! Now the same with : 1.) On startup of form2 the first dynamic item is focused correctly due to Code: [Select]activeControl := TCheckBox(self.pnlMainOperate.Controls[0]);2.) Pressing focusses the last button in the lower panel (with the max Taborder in the lower panel) 2.) Pressing focusses the previous button in the lower panel ... and so on. After the first button in the lower panel is reached the LAST DYNAMICALLY created TWIncontrol is focussed. So far so good. But pressing again does not set the focus to the previous element but to nothing at all or something invisible. Pressing again sets the focus to the Last button in the lower panel. ---------------------------------------------------------------------- hy · 2014-11-13 17:39 I just found out that everything (seems to) work fine when the dynamically created controls are NOT on a TPanel. So probably the TPanel screws the behaviour of navigating on the form (in WS gtk2). But anyway I need a solution for this. ---------------------------------------------------------------------- Never · 2014-11-13 17:54 This might do the job for you Code: [Select]SelectNextprobably under the exit event ---------------------------------------------------------------------- hy · 2014-11-13 18:17 Thanks never I will give it a try I filed a bug report. actually it's the TPanel which screws it up. If I put the items onto the form directly or if I use a groupbox everything works as expected. ---------------------------------------------------------------------- hy · 2014-11-13 18:23 SelectNext doesn't work either. Forward selects only the comboboxes (for whatever reason) backward doesn't do anything ---------------------------------------------------------------------- hy · 2014-11-13 18:45 NEVER: You are right SelectNext saved me the day. On my first try I've put it into the keydown event and forgot to set key:=0 Now that Ive done it it works. Thanks a lot. ---------------------------------------------------------------------- Never · 2014-11-13 19:22 glad you get the job done ---------------------------------------------------------------------- User137 · 2014-11-13 20:28 Isn't there some automation with the tab order? No control can have the same TabOrder, so at some point it compares to rest of the controls and sets the value to something new. So if i were to guess, you start by just creating the checkboxes and not touching taborder at all yet. Then afterwards go through them from last to first order setting the TabOrders. ---------------------------------------------------------------------- hy · 2014-11-13 20:30 The TabOrder is in perfect state after creating. I double checked it. But thanks for trying.