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.