Generic Msgbox C++ / UMG

Hi there

First of all, im new to UE4 and C++ coding in general so bare with me if its obivious…

Im trying to make a kind of generic MsgBox like you have in Dot.Net and Windows in general for my game. I’ve done 2 enums for the MsgBoxType and the MsgBoxReply and a function to make the MsgBox show in the game. The part im missing is how to make the function wait for the user input to give the type of reply as return value.

Enums



UENUM(BlueprintType)
enum class EMsgBoxType : uint8
{
    E1Button        UMETA(DisplayName = "1 Button"),
    E2Buttons      UMETA(DisplayName = "2 Buttons"),
};

UENUM(BlueprintType)
enum class EMsgBoxReply : uint8
{
    EMain            UMETA(DisplayName = "Main"),
    ESecondary   UMETA(DisplayName = "Secondary"),
    ENone            UMETA(DisplayName = "None"),
};


Function header code



UFUNCTION(BlueprintCallable, Category = "MsgBox")
EMsgBoxReply ShowMsgBox(EMsgBoxType msgBoxType, FString headerText, FString mainButtonText, FString secondaryButtonText);

EMsgBoxReply msgBoxReply;


CPP code



EMsgBoxReply UUIManager::ShowMsgBox(EMsgBoxType msgBoxType, FString headerText, FString mainButtonText, FString secondaryButtonText)
{
    msgBoxReply = EMsgBoxReply::ENone;

    switch (msgBoxType)
    {
    case EMsgBoxType::E1Button:
    {
            currentMsgBox = CreateWidget<UMsgBox>(GetWorld()->GetFirstPlayerController(), msgBox1Button);
            currentMsgBox->SetMainButtonText(FText::FromString(mainButtonText));
    }
    case EMsgBoxType::E2Buttons:
    {
            currentMsgBox = CreateWidget<UMsgBox>(GetWorld()->GetFirstPlayerController(), msgBox2Buttons);
            currentMsgBox->SetMainButtonText(FText::FromString(mainButtonText));
            currentMsgBox->SetSecondaryButtonText(FText::FromString(secondaryButtonText));
    }
    }

    currentMsgBox->SetMsgBoxHeaderText(FText::FromString(headerText));
    currentMsgBox->AddToViewport();


    // Make the function wait until user click on a button, the UserWidget is changing the msgBoxReply value when the user click on a button but its already too late for the return value.


    return msgBoxReply;
}


Any help would be more than welcome, iv’e looked at DELEGATE but in this case its doesnt seems to be able to fit my needs…