Show Alert

Alert is just like notification just that it has an option to have up to 2 buttons and wait for the user to click one of the buttons.

For that case, I made an async call that will return when one of the buttons clicked, or when the duration of the alert is timed out.

Just like in the previous page, there's a function called ShowAlert that takes a widget of type AlertWidget.

AlertWidget is a child of NotificationWidget.

Setup Buttons

To setup delegates for the buttons so they could work with this async node, we need to call does 2 functions.

Simply create a button, bind the on-click delegate, and call the matching action that you need.

Once you call the functions you need from the user widget, you are ready to go.

OnRemovedFromParent will be called either on a button click or when the widget is removed from the parent.

Blueprint

C++

UAsyncAlertWidget* AlertWidget = UAsyncAlertWidget::ShowAlert(this, /*AlertWidget object goes here*/);
AlertWidget->OnPrimaryButtonClicked.AddDynamic(...);
AlertWidget->OnSecondaryButtonClicked.AddDynamic(...);
AlertWidget->OnRemovedFromParent.AddDynamic(...);
AlertWidget->Activate();

Last updated