Understanding FToolBarBuilder::AddToolBarButton()


I have a custom plugin that has this following function that adds a button to the toolbar:

void HamadsPluginModule::AddToolbarExtension(FToolBarBuilder &builder)
	UE_LOG(MyPlugin, Log, TEXT("Starting Extension logic"));

	builder.AddToolBarButton(FHamadsPluginCommands::Get().MyButton, NAME_None, LOCTEXT("MyButton_Override", "My Button"), LOCTEXT("MyButton_ToolTipOverride", "Click me to display a message"), TAttribute<FSlateIcon>(), "HamadsPluginAwesomeButton");

I want to just better understand AddToolBarButton() since I essentially copied it from somewhere and edited it. So I’d like to understand its parameters:

1- The 2nd param: takes in an extension hook. That has been already defined while initializing this delegate, I’m wondering why would it need another hook in here?

2- 3rd param: LOCTEXT() if I’m correct is “localized text”, so I can have my buttons text localized. Could someone explain what is its first param, in this case this value MyButton_Override ? (it was WorldProperties_Override, but renamed it to fit the name of my button). I think this is like a key/value pair, so where can I define MyButton_Override?

4- 5th param: TAttribute(). This is obviously the icon for the button, I’m wondering what syntax should I use to set it up and where can I store the icon? Is it possible that I can make it reside in my plugin’s resource folder?

5- last param: What is a tutorial highlight?? What should I do here?

That’s it, and thanks!

So, any help?

I can hopefully answer the last two points.

You can indeed use icons specific to your plugin. You would store them in a style set specific to your plugin, and then use that style set to populate an FSlateIcon instance. There was a similar question about handing this before, so you can also check out the answer to that: Want to set an icon for my new Editor Module. How do I do this? - C++ - Epic Developer Community Forums

The tutorial highlight is something used by the tutorial that you see when you first run the editor, you should probably just use NAME_None there.

Though it doesn’t completely cover my questions, I think that was very useful. I can probably worry about LOCTEXT() later as it’s not a big deal at this point. Thanks for the help!