How to open an Editor Widget Utility tab from code?

Hi,

Just had the same issue.
My workaround was the following:

  • In IBlutilityModule.h, I added following public method:

     virtual void StartEditorWidget(class UWidgetBlueprint* Blueprint) const = 0;
    
  • In AssetTypeActions_EditorUtilityWidgetBlueprint.h, I make the method ExecuteRun public

  • Then in BlutilityModule.cpp

    include “AssetTypeActions_Base.h”

    void StartEditorWidget(UWidgetBlueprint* Blueprint) const override
    {
    if (Blueprint != nullptr)
    {
    TArray<UObject*> BlueprintArray;
    BlueprintArray.Add(Blueprint);
    auto Blueprints = FAssetTypeActions_Base::GetTypedWeakObjectPtrs(BlueprintArray);

          	FAssetTypeActions_EditorUtilityWidgetBlueprint obj;
          	obj.ExecuteRun(Blueprints);
          }
    }
    

Now to call a your Editor Widget:

IBlutilityModule* BlutilityModule = FModuleManager::GetModulePtr<IBlutilityModule>("Blutility");

const FStringAssetReference MyWidget_AssetPath("/FolderOfMyWidget/WidgetName.WidgetName");

UObject* MyWidgetObj = MyWidget_AssetPath.TryLoad();
UWidgetBlueprint* MyWidget = Cast<UWidgetBlueprint>(MyWidgetObj );
  StartEditorWidget(MyWidget);

The part where you find the path of your asset can be a bit tricky, fortunately, unreal editor provides an easy way to retrieve it using “Copy Reference” method:

281547-findpath.jpg

Now you just have to CTRL+V your asset path in your IDE and here you go.

And last thing, do not forget to add a few dependencies in your module:
“Blutility”,
“UMG”,
“UMGEditor”,

Hope this helps!

PS: you might need a few other includes and a few other modules to declare for your own plugin to make everything compile but it works!