Pause Game and Show Pause Menu when game window is minimized or lost focus

Hello! I need to pause the game and show my pause menu when the game window has lost focus (task manager is open, Alt+Tab is pressed, the game application is minimized, etc.). How to intercept this event?

you can bind to FSlateApplication::OnApplicationActivationStateChanged and show your pause menu or do whatever logic you need.

something like this:
if (FSlateApplication::IsInitialized())
FSlateApplication::Get().OnApplicationActivationStateChanged().AddUObject(this, &AMyPlayerController::OnApplicationDeactivated);