How to create a Confirm Dialog Message

Greetings all,

Just want to know if there is a way to code a UI in Unreal from Blueprint or somethng else in Unreal ?

Let’s say we are in game and the player press Quit button for quite the game. So i want the program ask the player: “Are you sure you want to quit?” with the option “Yes” and “No” buttons/options.

Thank you for your attention.

Greetings.

Phil

1 Like

Hi

Made this recently. I do this in a BP, so I reference the Widget first.

Like this.

Don’t know if you’ve solved this yet, but I solved this using widgets. You can have a Vertical box (or Horizontal box) that gets toggled when the “Quit Game” button is pressed by changing its visibility.

Here’s the utility function I’ve to show message boxes in Unreal:

EAppReturnType::Type UAirBlueprintLib::ShowMessage(EAppMsgType::Type message_type, const std::string& message, const std::string& title)
{
    FText title_text = FText::FromString(title.c_str());

    return FMessageDialog::Open(message_type,
        FText::FromString(message.c_str()),
        &title_text);
}
1 Like

Here’s the fastest implementation I found, if you don’t need to have a “good looking dialog” but just a basic confirmation prompt:

#include "Misc/MessageDialog.h"

EAppReturnType::Type Result = FMessageDialog::Open(EAppMsgType::OkCancel, FText::FromString(TEXT("Do you want to proceed?")));
if (Result == EAppReturnType::Ok) {
	// User clicked "Yes"
} else {
	// User clicked "No" or closed the dialog
}