How to do it...

  1. Open your editor module's header file (Chapter_10Editor.h) and add the following code:
class FChapter_10EditorModule: public IModuleInterface 
{
virtual void StartupModule() override;
virtual void ShutdownModule() override;

TArray< TSharedPtr<IAssetTypeActions> > CreatedAssetTypeActions;

TSharedPtr<FExtender> ToolbarExtender;
TSharedPtr<const FExtensionBase> Extension;

IConsoleCommand* DisplayTestCommand;
IConsoleCommand* DisplayUserSpecifiedWindow;
  1. Add the following code within the implementation of StartupModule:
DisplayTestCommand = IConsoleManager::Get().RegisterConsoleCommand(TEXT("DisplayTestCommandWindow"), TEXT("test"), FConsoleCommandDelegate::CreateRaw(this, &FChapter_10EditorModule::DisplayWindow, FString(TEXT("Test Command Window"))), ECVF_Default);

DisplayUserSpecifiedWindow = IConsoleManager::Get().RegisterConsoleCommand(TEXT("DisplayWindow"), TEXT("test"), FConsoleCommandWithArgsDelegate::CreateLambda(
[&](const TArray< FString >& Args)
{
FString WindowTitle;
for (FString Arg : Args)
{
WindowTitle += Arg;
WindowTitle.AppendChar(' ');
}
this->DisplayWindow(WindowTitle);
}

), ECVF_Default);
  1. Inside ShutdownModule, add the following code:
if(DisplayTestCommand)
{
IConsoleManager::Get().UnregisterConsoleObject(DisplayTestCommand);
DisplayTestCommand = nullptr;
}

if(DisplayUserSpecifiedWindow)
{
IConsoleManager::Get().UnregisterConsoleObject(DisplayUserSpecifiedWindow);
DisplayUserSpecifiedWindow = nullptr;
}
  1. Implement the following function in the editor module (Chapter_10Editor.h):
void DisplayWindow(FString WindowTitle) 
{ 
  TSharedRef<SWindow> CookbookWindow = SNew(SWindow) 
  .Title(FText::FromString(WindowTitle)) 
  .ClientSize(FVector2D(800, 400)) 
  .SupportsMaximize(false) 
  .SupportsMinimize(false); 
  IMainFrameModule& MainFrameModule = 
FModuleManager::LoadModuleChecked<IMainFrameModule>
(TEXT("MainFrame")); if (MainFrameModule.GetParentWindow().IsValid()) { FSlateApplication::Get().AddWindowAsNativeChild
(CookbookWindow, MainFrameModule.GetParentWindow()
.ToSharedRef()); } else { FSlateApplication::Get().AddWindow(CookbookWindow); } }
  1. Compile your code and launch the editor.
  2. Play the level, and then hit the tilde key to bring up the console.
  3. Type DisplayTestCommandWindow and hit Enter:

  1. You should see our tutorial window open up: