How can I get a callback when switching between tabs

Hello everyone!
I have created a tab manager and I want to get a callback when the tab is switched. What should I do? Here’s my initial code:



  TSharedRef<FWorkspaceItem> RootMenuGroup = FWorkspaceItem::NewGroup(LOCTEXT("CategoryOptionRootName", "Root"));
    FilegroupMenuGroup = RootMenuGroup->AddGroup(LOCTEXT("CategoryOptionFileGroupName", "File Group Tabs"));
    {
        TSharedRef<SDockTab> DockTab =
            SNew(SDockTab)
            .TabRole(ETabRole::MajorTab)
            .Label(LOCTEXT("CategoryOptionRootTab", "Main Tab"));

        TabManager = FGlobalTabmanager::Get()->NewTabManager(DockTab);
        TabManager->SetCanDoDragOperation(false);
    }    
    EditorTabStack = FTabManager::NewStack();
    EditorTabStack ->AddTab(CategoryOptionMainTabId1, ETabState::OpenedTab);
    EditorTabStack ->AddTab(CategoryOptionMainTabId2, ETabState::OpenedTab);
    EditorTabStack ->AddTab(CategoryOptionMainTabId3, ETabState::OpenedTab);


slatetab.png

and all my tabs are dynamically. Anyone can help me. Thanks in advance.

There is an FOnActiveTabChanged delegate you can hook into. Look at TabManager.h

Yep, and hooking into those delegates from c++ usually looks like OnActiveTabChanged.AddDynamic(this, &class:func())

OH…I found it! Thanks ExtraLifeMatt and RyuMaster. You are very kind man.:slight_smile: