Help with scripting OnActivateTab Method

Hello,

I would like to write a script that if you press on a new tab then automatically you will go back to the old tab. This is just a generalization of what I intend to do. I used the event OnActivateTab
This is the function:

Function OnActivateTab(activateTabData)

Dim objCmd
Set objCmd = DOpus.CreateCommand    
objCmd.SetSourceTab(activateTabData.OldTab)

End Function
It generate no errors but it just navigate to the new tab instead of staying in the old tab.
Any help will be appreciated.

Thanks

What do you need this for? There are ways to open new tabs without activating them, which might be better.

I am just testing if it can be done. What I would like to do is have an if statement in this function which will decide if the folder being navigated is VALID (according to the if statement) and if it is not valid then to go back to the old tab and not navigating to the new one. If you have a different idea I would be more than happy to accept it.

Thanks

If there is an event that can block navigating to a new tab by returning TRUE it is better than what I am using but I did not find anything that can help me that.

There is an event which can cancel navigation. Jon mentioned this in your other thread.

This time it is not a folder it is a new tab that is being opened or being navigated to. I would like to block access to this new tab or old tab because it is not accessible. I am not an expert in JavaScript I am writing in C++. My problem is not with the language I can deal with that. I tried a new way of implementing it I will use the method OnOpenTab(openTabData) and if the tab being opened is not valid it should be immediately closed so I added the line
Dim Execute
set Execute = DOpus.NewCommand
Execute.RunCommand("Go TABCLOSE PATH=""" & openTabData.Tab & """")
I thought that this command will close the newly opened tab but it doesn't do anything at all

I would appreciate your patience and collaborating with me regarding this matter. It is quite important that I will be able to implement it.

Thank you

This will close every tab you open. Add logic as needed to decide which tabs to close.

option explicit

Function OnInit(initData)
	initData.name = "BlockTabOpen"
	initData.version = "1.0"
	initData.copyright = "(c) 2018 Leo Davidson"
	initData.desc = "Example script"
	initData.default_enable = true
	initData.min_version = "12.0"
End Function

Function OnOpenTab(openTabData)
	Dim cmd
	Set cmd = DOpus.Create.Command()
	cmd.SetSourceTab openTabData.tab

	cmd.RunCommand "Go TABCLOSE"
End Function

But you may be able to do things a better way, depending on how the tabs are being opened. If something is opening invalid folders, you might be able to change that thing to stop it opening them in the first place. Not sure without knowing the details, though.

Thanks a lot Leo.

Regards