Search code examples
formslibreofficelibreoffice-base

LibreOffice Base; Tab order from mainform to subform


I have a form with a mainform and a subform. When the user is in the textbox, which is the closest to the subform, and the user press Tab, it has to jump into the subform, but it doesn't. It jumps to the textbox AFTER the subform. When the user is in the last textbox of the mainform and te user press tab, then it jumps into the subform.

How do I make sure, that the user will jump to the subform when he is in the textbox, which is the closest one to the subform?

Example image:

example image


Solution

  • Tab order in the UI does not account for controls on subforms, but this can be done programmatically. Set a LO Basic macro on the When losing focus Event for the control that is closest to the grid/table control on the subform. That is the control that, when you tab past it, you want to go to the grid. For that event, run a macro like this, where grid1 is the table/grid control:

    root_doc = ThisComponent
    form_container = root_doc.Drawpage.Forms
    form_ctrlr = root_doc.getCurrentController()
    sub_frm = form_container.getByName("Sub_Form")
    tab_target = sub_frm.getByName("grid1")
    
    form_ctrlr.getControl(tab_target).setFocus()
    

    You also will need to set up a similar macro when leaving grid1 as, because it is in the subform, it is not accounted for in the tab order.

    Hat tip to probe1@ooForum.