Getting currently selected folder from Content Browser in c++?

Hi everyone,
I’m writing some automation tools to let our artists mass edit asset properties that are not available in the Bulk Editor, like a MaterialInstance’s Parent Material.

I can iterate through a list of selected assets, and also through all assets of type given a folder path, but I can’t figure out how to automatically retrieve the folder path of the currently selected folder from the Content Browser.

Anyone know how to do that?

Thanks!

You can right click and say copy reference, that will give you the folder path if thats what you mean?

In “ContentBrowserDelegates.h” there is this delegate:



/** Called when a path is selected in the path picker */
DECLARE_DELEGATE_OneParam(FOnPathSelected, const FString& /*Path*/);


Subscribe to that event.
Whenever user selects a folder it will return to your subscribed function path to the folder selected.

The problem with that is the delegate instance “OnPathSelected” is within a struct called “FPathPickerConfig” then only way to get a config is declaring your own to then pass it as a reference to:



*virtual TSharedRef<class SWidget> CreatePathPicker(const FPathPickerConfig& PathPickerConfig)


That is Slate code, they expect you to create your own panel and setup a Slate Widget for it with your own *FPathPickerConfig *struct as param.

Inside “SContentBrowser.cpp” you can see how they subscribe a function to their FPathPickerConfig:



TSharedRef<SWidget> SContentBrowser::GetPathPickerContent()
{
    FPathPickerConfig PathPickerConfig;

    //......

**  PathPickerConfig.OnPathSelected** = FOnPathSelected::CreateSP(this, &SContentBrowser::PathPickerPathSelected);
    //.......


Awesome, thanks BrUnO, gonna give it a try!

For posterity: No need for deligates as Ville Nurmi has pointed out here:
https://forums.unrealengine.com/deve…ontent-browser

Can just



TArray<FString> Folders;
FContentBrowserModule& ContentBrowserModule = FModuleManager::LoadModuleChecked<FContentBrowserModule>("ContentBrowser");
IContentBrowserSingleton& ContentBrowserSingleton = ContentBrowserModule.Get();
ContentBrowserSingleton.[GetSelectedFolders](https://docs.unrealengine.com/en-US/API/Editor/ContentBrowser/IContentBrowserSingleton/GetSelectedFolders/index.html)(Folders);

Nice find, I couldn’t find anything like that in source back then.

I get on ContentBrowserSingleton.GetSelectedFolders(Folders); an Error: C2027.
How i can fix this?

EDIT: I fixed this. VS19 dont tell me, he need an include. include “IContentBrowserSingleton.h”