So I’m looking through some of the code that constructs the default editor toolbar menus and wondering if it’s possible to add an item to one of them via a plugin.
Is there an overview of the command/menu/interface structure somewhere? I work much better with imagery and this area seems to be particularly complex. If there isn’t, if someone helps me understand it I’ll draw one up and throw it on the wiki.
It sort of seems like the way to go is to loop through the toolbar and reconstruct it, while adding my changes. Would that make sense? Is there any way to just intercept the ONE delegate I want to replace?
I think what I need is a way to create a new MenuBuilder object and somehow associate it with a child of an existing structure, then just AddMenuItem(). It doesn’t look like there’s any way to navigate the slate hierarchy though?
Thanks for your reply! That’s basically what I had. I changed a couple of things up but it’s still not appearing in the target submenu. I just found a potential collision between my command name and a command handler though, so I’ll fix that real quick. Nope, that wasn’t it.
Can you tell me a bit about commands? When you do MapAction(), is it kind of a singleton or can you map multiple actions? In my instance I’m creating a new FUICommandList just for this menu item. (Edit: Actually, I’ve switched to just using one FUICommandList object, same result but tidier code).
Also, under RegisterCommands() does it matter what EUserInterfaceActionType I use? The menu I’m adding to actually has radio buttons in it, but that’s a problem for later, so for now I’m using EUserInterfaceActionType::Button. Will that still work?
By the same token can I re-use the MenuExtender, or do I need a new one for each item I’m adding? If I can, do I call AddExtender once at the end, or for each item? I’m guessing yes, as you pass in PluginCommands so that it can create the menubuilder used by the delegate, which then references a specific command from the list by name.
Does it matter that the submenu I’m trying to insert into is a toolbar submenu? I tried converting everything into toolbar-y stuff but didn’t get very far.
As you can see I’m down to checking obvious specifics.
UICommands are just a set of action mappings so you can use it multiple times in different places. Either in form of a menu button or shortcut - for example, note that file and edit menu on the top menu bar are the same in level editor window and in blueprint editor.
Also note that you’re using something thats called FUICommandList which means you can put there any number of commands there. When you use MapAction you’re binding a function to given command, I’m not sure what do you mean by “mapping multiple actions”. But keep in mind that if you want to extend any menu you dont have to use UICommands. Yes, it is recommended but you dont have to.
If you want radio buttons you should use EUserInterfaceActionType::RadioButton, if you just want to display a menu entry, go with Button or Toggle button. I can’t really tell what and how you’re doing stuff without seeing your code.
You can add any number of entries to a given extender. You do that in the function youre binding when calling AddMenuExtension (&FPluginCreatorModule::AddMenuExtension in the example above)
It shouldnt matter as long as youre using correct extender: MenuExtender for menus and ToolbarEtender for toolbars.
You should take a look at samples provided in STestSuite.cpp file in the source code. You will find there everything you need to get started with slate menus.
If you will still have problems, please, paste your code so I can get better understanding of what you’re trying to achieve.
UI_COMMAND(UseMyThingLighting, "MyThing", "Do some stuff", EUserInterfaceActionType::Button, FInputGesture());
The net effect is nothing happens. No errors or warnings, just zilch. It makes me wonder if this particular menu is somehow static and not ever updated.
With most things so far I’ve found that the problem is just with my understanding of it. So far everything you’ve said has made sense and confirmed what i thought, so let’s check my thinking in this case:
Most of slate has event hooks for when an element is instantiated, in case it’s been modified, yeah?
In this case due to what I can see with how the menu I want to change is constructed, it might not be accessible in the same way.
Would that be right, or are they all the same and all accessible?
LevelEditorBuildLightingQuality menu is a submenu and if you go to LevelEditorToolBar.cpp you’ll see that it is hardcoded and theres no way to extend it. However, you shoud be able to extend Lighting menu.
Keep in mind that GetMenuExtensibilityManager refers to the top menu with File, Edit and View options, when GetToolBarExtensibilityManager refers to the toolbar with Play, compile and build lighting buttons.
Nah, I would say you’ve got only few places that you can extend editor UI. But if you think about, it’s actually pretty reasonable and sufficient in most cases. Imagine that you have extension manager for each menu/submenu in the editor, that would take quite big amount of code to do. And how often potential Editor user would like to extend LightingBuildInfo submenu? Well, not very often, I guess ; )
My advice would be to go ahead and create your own button/menu for toolbar and get things done there. It will be easier to implement for your and easier to access for users in the future.