x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

AnswerHub Maintenance

Background maintenance is scheduled to occur between 9 - 11am EDT on Tuesday, May 21. Site operation may be slower than normal during this time and a brief interruption in operation may be observed

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.

Product Version: UE 4.8
Tags:
more ▼

asked Sep 21 '15 at 04:26 PM in C++ Programming

avatar image

isaacvega
11 1 4 7

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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?

more ▼

answered Sep 22 '15 at 07:51 AM

avatar image

isaacvega
11 1 4 7

avatar image isaacvega Sep 22 '15 at 08:23 AM

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?

avatar image Penanito Feb 20 '16 at 03:01 AM

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

avatar image isaacvega Feb 21 '16 at 07:19 PM

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.

avatar image Chuman Jun 18 '18 at 06:50 PM

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question