2

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

4

2 回答 2

1

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.

于 2015-01-31T05:08:53.320 回答
1

I had to add one more line to get the code to work. See code.

Dim root_doc As Object
Dim form_container, form_ctrlr As Object
Dim main_frm, sub_frm, sub_frm_grd As Object
root_doc = ThisComponent
form_container = root_doc.Drawpage.Forms
form_ctrlr = root_doc.getCurrentController()
main_frm = form_container.getByName("MainForm")
sub_frm = main_frm.getByName("SubForm")
sub_frm_grd = sub_frm.getByName("SubForm_Grid")
'set focus to grid control
form_ctrlr.getControl(sub_frm_grd).setFocus()
于 2016-03-07T01:15:09.037 回答