sarram
(Cube)
1
Problem: need to use OpenDirectoryDialog function.
I tried this: FDesktopPlatformModule::Get()->OpenDirectoryDialog()
But, can’t get ParentWindowHandle.
Tried to use this:
TSharedPtr<SWindow> ParentWindow = FSlateApplication::Get().FindWidgetWindow(AsShared());
const void* ParentWindowHandle = (ParentWindow.IsValid() && ParentWindow->GetNativeWindow().IsValid())
? ParentWindow->GetNativeWindow()->GetOSWindowHandle()
: nullptr;
from https://answers.unrealengine.com/questions/395516/opening-a-file-dialog-from-a-plugin.html?sort=oldest thread. But get error “‘AsShared’: identifier not found”.
Also tried this:
const void* ParentWindowHandle = GEngine->GameViewport->GetWindow()->GetNativeWindow()->GetOSWindowHandle();
but still no luck.
Emaer
(Emaer)
2
AsShared isn’t free function and require object context: instance of class derived from TSharedFromThis<T>. (all classes derived from SWidget)
Are You trying pass a nullptr to OpenDirectoryDialog?
1 Like
Jaytheway
(Jaytheway)
3
In case someone is going to have problems with this, solution described here: Unresolved External Symbols - Pipeline & Plugins - Unreal Engine Forums
But basically you need to add “SlateCore” module to your *.Build.cs to to be able to use this:
...GEngine->GameViewport->GetWindow()->GetNativeWindow()->GetOSWindowHandle()
… as
const void* ParentWindowHandle
within this function:
FDesktopPlatformModule::Get()->OpenDirectoryDialog(GEngine->GameViewport->GetWindow()->GetNativeWindow()->GetOSWindowHandle(), dialogTitle, defPath, folderPath);
P.S. There’s probably more elegant way of doing this. But this worked for me.