Creating a new tab in a plugin

Hey everyone!

I’m having a problem with creating a tabbed window that appears docked in the level editor, ala the scene outliner. I’ve gone over some of the relevant source code, but it seems that what happens is that the scene outliner is registered to the level editor’s tab manager during the initialization of the level editor (i.e. hardcoded into the source itself, and not created as the result of plugging into an extensibility point).

My understanding of a tab manager is that it is an object that is responsible for the instantiation (via a callback) of each tab, as well as its orientation and “dockedness” in relation to other tabs. It seems you have to register a tab with a unique string and a special callback, then you create the tab by telling the manager to instantiate a certain tab ID. So far so good…

But, since the level editor’s tab manager is null when my module starts, I can’t register a tab with it. When I try to create a tab using the level editor’s tab manager (later, as a result of pressing a button I added to the UI), but that tab is registered with the global tab manager, I get an “unknown tab” tab in the level editor. Which makes sense of course; I wouldn’t expect the tab managers to cascade tab definitions (but I had to try anyway).

So I seem to be stuck. I can think of a few possible solutions:

A) Can I create a new tab and parent it to the level editor? I’ve tried doing something like “newTab.SetParent(LevelManager.GetTab().GetParent())” but that has no effect (perhaps because LevelManager.GetTab().GetParent() returns the parent tab manager, i.e. the global tab manager).

B) Can I run code in my module after the level manager is created and fully loaded?

A third option is that I am completely missing the point somewhere, but I can’t seem to find where that may be. Any guidance on this topic would be greatly appreciated.


Yes, you can run code in your module after the level manager is created and loaded. Though there doesn’t appear to be an event you could use outside of a menu item, or button you register. Don’t do (A).

You don’t appear to be missing anything, you just appear to be the first person to have tried this from a plugin. I’ll check in a fix to the level module that adds an event you can hook that will be fired when the tab manager is registered.

Change now live in master: