So I want to create an editor module for my project create a dropdown menu in the toolbar much like the “Add to project” dropdown right next to the Editor mode dropdown:
I am able to create a menu like that just fine but my issue comes from how I want to populate it. I looked at the source code and as far as I can tell these types of menus are always created all at once. But I want to register the dropdown and then allow other modules/plugins to add to it. I cannot for the life of me find any examples where this is done.
The only thing I found that kinda did what I wanted was in the “OnGetContent” callback for the widget that is created here. That looks like this:
UToolMenu* Menu = UToolMenus::Get()->ExtendMenu("LevelEditor.LevelEditorToolBar.AssetsToolBar");
{
FToolMenuSection* Section = Menu->FindSection("MySection");
if (Section)
{
FToolMenuEntry* Entry= Section->FindEntry("MyEntry");
if (Entry)
{
Entry->ToolBarData.ComboButtonContextMenuGenerator.OnGetContent.BindRaw(
this, &FMyModule::GenerateToolbarMenuEntry);
}
}
}
and in the callback I bind there I am able to generate buttons for the dropdown.
Sadly this isn’t workable as “OnGetContent” is a single delegate so I can’t bind multiple functions to it. So the last thing to bind will be the only thing visible in the dropdown.
Any ideas?