Hello.
I am in the process of extending the editor as a module and I have added buttons through ToolbarExtender.
From the button actions, I spawn SDockTabs and populate them with content (dummy data so far). Although the tab spawning works correctly, I would like to get more details on the usage of the tab spawners and possible drawbacks for the method I use.
While implementing it, I also found some pieces of undocumented code that I hope someone can help me clarify.
About InsertNewDocumentTab
Create a new TabManager from a simple SDockTab. Here I followed the SlateViewer project, I only care about the SpawnTestSuite1 and the DocumentsTestTab (inside STestSuite). I want to follow the same parent-child between SpawnTestSuite1 and DocumentsTestTab: TestSuite1Tab is created as a new tab manager and later registers a tab spawner for the DocumentsTestTab . A new tab is spawned with the method InsertNewDocumentTab
Why is the function called InsertNewDocumentTab instead of InsertNewTab? What’s the context of the Document word in this function? I am concerned because I am planning to later include a nested viewport tab, details tab and more.
InsertNewDocumentTab also requires an ESearchPreference enum, can someone explain me what’s the difference in using FTabManager::ESearchPreference::RequireClosedTab & PreferLiveTab?
About dynamically generating Id on tabs
When spawning a NewTab I want to be able to change the label of “MyTabTile” in runtime.
.Label(NSLOCTEXT("MyTabTitle", "TabTitle", "My Tab Title"));
I tried the simplest method looking at STimelineTrack code
TAttribute NameAttribute;
TSharedRef NewSpawnedTab = SNew(SDockTab)
.TabRole(ETabRole::DocumentTab)
.Label(NameAttribute);
But I don’t understand how to initialize without callbacks the TAttribute, is it possible? Could you point me an example in the engine that uses a simple initialization? I used this piece of code as a reference
TAttribute CurrentAssetTitle = TAttribute::Create(TAttribute::FGetter::CreateSP(this, &SFlipbookKeyframeWidget::GetKeyframeAssetName));
Please elaborate what does the CreateSP work? With that clear, I would probably be able to assign a variable without introducing a function.
My major problem using the callback approach, is that the function should be contained within a class based on SCompoundWidget. Any change I can assign the function to CreateSP without being an SCompountWidget?
Should I also UnregisterTabSpawner
When creating my own Tab Manager and spawning tabs through it, should I also make sure to unregister the TabSpawners?
Restoring a layout from my own TabManager
I noticed that when using the FGlobalTabmanager::Get()->RegisterTabSpawner, the layout of the tabs is saved when re-opening the editor, but it doesn’t work the same way when using my own tab manager.
Can you point out the missing pieces to have my own TabManager layout being restored after re-opening the editor?
I hope I made my self clear, looking forward some help.
Regards