Can I switch Tabs using UNO methods?

I’ve created a Tabbed dialog using …awt.tab.UnoControlTabPageContainer service family. Clicks on tabs operate fine. I would like to permute tabs using keyboard event handlers next to mouse clicks.

I cannot identify a method that switches tabs via scripting.

Ctrl+PgUp/Down is the built-in shortcut navigating through tabs.

Thanks for this

What I’m looking for is an UNO method to be scripted in combination with Alt+underlined letter - e.g. ~Tabname - accelerator keys

Based on the sample code by our Finnish friend @Pertsa

Sub Main
REM globalscope.basiclibraries.loadlibrary("XrayTool")
dlg = CreateUnoDialog(DialogLibraries.Standard.UserForm1)
tc = dlg.Controls(22)
tc.activateTab(2)
REM XrayTool._Main.Xray(tc)

dlg.execute()
End Sub

The tab index seems to be 1-based.
The dialog model is useless in this case. The corresponding model property is “MultiPageValue”.
Property ActiveTabID (read-only) gets the active tab ID.

@LibreOfficiant
and everyone…
'Property: MultiPageValue - Value: 4 (I had set it when coding my VBA-tuning)
Dim oControl As Object
oControl = MyForm1.getControl(“MultiPage1”) 'MyForm1 is my Dialog box name
oControl.Model.setPropetyValue(“MultiPageValue”, 1) 'or whatever you want (in limit of the Page count :wink:)

Now it’s just a piece of cake to put a keylistener/event.
Research and more research

Indeed, I missed that property.

@Villeroy @Pertsa
Thanks for your answers. However a multi-page dialog does not convey the UI I’m currently interested in.

You’ll find attached the WiP document containing the Organizer.Controller.KeyListener_keyPressed routine that’s worrying me.
Scripting Tabbed Dialogs.odt (120.6 KB)

@LibreOfficiant

I was able to tune this up based on your tip. Quite laborious, but at least you can see the controls in design mode. :saluting_face:
TabDialogTest.odt (18.6 KB)

To switch between tabs, you need to set a new ActiveTabPageID value.
So in your example:

src.Controls(0).ActiveTabPageID=3

instead of

oTabsListener.ActivateTab(3)

Great !
Thanks

The answer was line# 49 in my Controller module. Stupid me !

You have done a voluminous and interesting job!

I want to avoid the tedious part of setting event handlers dynamically. I’m now evaluating the use of ScriptForge to relink copied controls to pre-defined listeners via SFDialogs.DialogControl read/write event properties.

@LibreOfficiant
It would be really nice if you could let us know when you have progressed to the point where the UI works seamlessly.

As for my own tuning I ran into a practically insurmountable problem trying to port my old VBA tuning to the LibreOffice Basic environment.
I got it to work as it originally did, but the API of the service I used has changed so much that the whole tuning is basically completely useless.
Thanks to your tip, I basically could build a new one by starting from a clean slate.

@LibreOfficiant and everyone
Here’s one way to give the impression of a MultiPage control:
MultiPageCheat.ods (17.5 KB)

Hi Pertti

Tabbed dialogs will be part of ScriptForge in LO 25.8, in two different flavours:

This is now documented in current help master copy:

Use LO latest build to test this

Hi

Thank you for sharing this information :slightly_smiling_face:

@LibreOfficiant and everyone
I found another way to get the MultiPage control to use and work (also in older LibreOffice versions). I exported the dialog (.xdl) and manually removed all the controls set on the Pages and then imported the .xdl to a new project. So now I can add controls on the pages on the fly, as well as set event listeners/handlers to them. To make this work don’t set any event’s on any possible controls set onto your Dialog in design mode, otherwise events will confuse the events that are set on the fly and vice versa.
I can take advantage of the location maps I created to the controllers in my previous project (to cheat MultiPage effect), now without need to hide or disable properties of any control.
Instead of function use sub with these:

Sub TopListen_WindowClosing
	Continue=false
	ThisComponent.setModified(False)
End Sub
Sub  TopListen_windowOpened
End Sub
Sub  TopListen_windowClosed
End Sub
Sub TopListen_windowMinimized
End Sub
Sub  TopListen_windowNormalized
End Sub
Sub  TopListen_windowActivated
End Sub
Sub  TopListen_windowDeactivated
End Sub
Sub  TopListen_disposing
End Sub

Let’s continue on this topic and expand possibilities. In fact, you can even build a Dialog in wich you can read the MultiPage Dialog template to a string and then build a new .xdl file by modifying your string with a string builder e.g to give your MultiPage control a page count you need and some properties (even set controls if you so like) and then save your achievements to a folder you wish. Then you can load it to your project and so on… You can even make a LibreOffice extension of your template builder Dialog or just add it to a tool box, say in Calc…

Cloning “Basic Macro Organizer” dialog with ScriptForge LibreOffice 25.8

what is that good for?
btw. meanwhile you should use:

url = uno.fileUrlToSystemPath(
            f'{doc.URL}/Scripts/python/{lib_name}' )
# instead of:
url = uno.fileUrlToSystemPath(
            '{}/{}'.format(doc.URL,'Scripts/python/'+lib_name))