Prevent losing focus when tabbing outside last object of dynamic subform


I have a subform that is created dynamically (by code)
When showing the subform with OBJECT SET SUBFORM I use GOTO OBJECT to set the focus to the first object
Question: How can I prevent that when tabbing outside the last object of the subform, another object in the form gets the focus? Ideally I want the first object of the subform again to get the focus

On losing focus of the last object -> set the focus to the first one ?

Thought of that, but when tabbing to the left (shift tab) I just want to go to the previous object
So I have to detect I am going outside the subform

if(Shift down)
//go to previous
//go to first
end if

Been there, I honestly couldn’t find a good solution.

One might think On Losing Focus + “GOTO OBJECT”, but of course, then you won’t be able to get out of the subform from the first and last objects (clicking is also a way of getting/losing focus). It is also not possible to know which direction the tab is moving.

Next, you’d think “capture tab and shift+tab keyboard shortcuts, instead of processing On Getting/Losing Focus”, but that requires a pair of hidden buttons whose behaviour you would toggle when the first or last object in the tab order has focus.

You might get the desires result, but then again, you have an enclosed circular tab system in the subform, which you can tab into but not tab out of.

So actually, for the first and last object, you need to differentiate a tabbing in from the parent form versus a return tab from the other end in the subform. And that’s when you start to think about giving up…

1 Like

Is it an input loop in the subform?
(I mean adding successive items to a list, in the same form, for example)

Yes, if you mean that I want the following:
Tabbing out of the last object of the subform is tabbing into the first object of the subform and vice versa
And I am not only talking about input fields, also checkboxes and 3d buttons can have a focus for example