Spawn new Tab instances from a TabManager

Hello, I am extending the editor and created a ToolbarExtender for the LovelEditorModule, basically a new button.
The button should spawn a new Tab instance every time is clicked.

The tab is created through a tab manager and then register a tab spawner, hoping this would suffice to have a tab “factory”, but my button is only able to spawn one instance of this tab.

Here I show you how I create a new Tab Manager and register a tab Spawner

 FMyEditorModule::StartupModule()
{
...
    TSharedRef<SDockTab> MyTab =
    		SNew(SDockTab)
    		.TabRole(ETabRole::MajorTab)
    		.Label(LOCTEXT("MyTab", "My Tab"))
    		.ToolTipText(LOCTEXT("My Tab", "Open My Tab."));
    
    	MyTabManager = FGlobalTabmanager::Get()->NewTabManager(MyTab);
    	TSharedRef<FWorkspaceItem> AppMenuGroup = BaseDataViewerTabManager->AddLocalWorkspaceMenuCategory(LOCTEXT("MyEditorModule", "My Editor Module"));
    
    	MyTabManager->RegisterTabSpawner(FName("MyTabName"), FOnSpawnTab::CreateRaw(this, &FMyEditorModule::CreateBaseViewerTab))
    		.SetDisplayName(NSLOCTEXT("MainTab", "MainTab", "Main Tab"))
    		.SetTooltipText(NSLOCTEXT("MainTab", "MainTabTooltip", "Main Tab."))
    		.SetGroup(AppMenuGroup)
    		.SetIcon(FSlateIcon(FEditorStyle::GetStyleSetName(), "Launcher.TabIcon"));
...
}

In my command list I include the action that opens the tab, this is what actually bind the button action to the creation of the tab.

	const FMyEditorCommands& Commands = FDMyEditorCommands::Get();
	
	CommandList->MapAction(
		Commands.Open,
		FExecuteAction::CreateRaw(this, &FMyEditorModule::OpenTab),
		FCanExecuteAction());

And implementing OpenTab

void FMyEditorModule::OpenTab()
{
	BaseDataViewerTabManager::Get()->InvokeTab(FTabId("MainTab"));
}

What do I need to to change to create a new instance of the “MainTab” every time I click the button?

For the tests I have done, I know I can use

FGlobalTabmanager::Get()->RegisterNomadTabSpawner

for the global tab manager, but haven’t found using another TabManager.

In any case, if it would be possible to use the GlobalTabmanager to spawn new Tab instances, how would that work?
Appreciate any corrections.
Thank you.

I find the solution in the SlateViewer, sorry but when learning and trying for the first time with slate, things get messier very quickly.
To actually generate the tabs use the following method

MyTabManager->InsertNewDocumentTab(...)

I don’t understand yet what does it mean the ESearchPreference enum (PreferLiveTab & RequireClosedTab), if someone can explain the difference on using one or the other.

Another problem I encounter restoring the tabs when re-opening the Editor, how do I make sure MyTabManager is properly restored?

I also realize that spawning a NewDocumentTab might be a limitation, because later on I want this tab to include a viewport, is that true?
What other options do I have to spawn tab in this way, without using InsertNewDocumentTab?

I thought I had commented here a bit ago but guess not, was just wondering If you ever got this working?

Hi, yeah I actually included a viewport without problems. As I stated in the answer, I used InsertNewdocumentTab.
About the ESearchPreference I quote

The search preference determines whether we prefer an open tab, or whether the tab next to which we spawn should be a closed tab whose location is saved in the layout.

There was a complete answer about this topic in UDN, am not sure that can be shared here.

Hi know that this is a really old post, but could you share some more of the details about your fix, I’m having the same issues trying to create multiple tabs from a tab manager.