Reputation: 263
The question and answer LibreOffice Base; Tab order from mainform to subform almost solve the issue I have, but not completely.
I have a table mytable
(id, name, textfield
). I'm displaying id
and name
in a form with a table layout (table control). I've added the column textfield
from the same table as a subform with a text box control (the reason is that I want to enter text with newlines, while being able to navigate the records quickly in the main table). Here's what it looks like in design view:
I've added this Basic macro, based on the two answers linked above:
Sub Main
Dim root_doc As Object
Dim form_container, form_ctrlr As Object
Dim main_frm, sub_frm, tab_target 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")
tab_target = sub_frm.getByName("TextField")
form_ctrlr.getControl(tab_target).setFocus()
End Sub
Now, if I add the macro on the event When losing focus
of the name
column, I do get focus on the textbox when pressing Tab, but on the next row.
If I add the macro to the event On key press
of the name
column, I get what I want when pressing e.g. Space
, but Tab
or Enter
only take me to the next row in the main form.
Is there a way to get this to work with Tab
?
Upvotes: 0
Views: 1101
Reputation: 263
Options to solve this, from the answers over at ask.libreoffice.org:
Just use the standard Ctrl + Tab
to switch focus.
Assign a macro to a custom key combination and use that. Not all combinations work, I settled on Shft + Enter
.
And the macro (provided by user Ratslinger):
Sub Main
Dim oForm, oCtrlr, oField As Object
oForm = ThisComponent.Drawpage.Forms.getByName("MainForm")
oCtrlr = ThisComponent.getCurrentController()
oField = main_frm.getByName("TextField")
oCtrlr.getControl(oField).setFocus()
End Sub
Upvotes: 0