Actually you can also handle window close requests in user code, without ever touching the engine source.
The viewport client does have a delegate for exactly that purpose, which can be obtained by the UGameViewportClient::OnWindowCloseRequested()
accessor.
The world viewport client can be obtained with the UGameInstance::GetGameViewportClient()
method, but beware that this is only available after the GameInstance has been initialized, but not yet in the UGameInstance::Init()
method.
So, as code example which will call delegateToCall if someone tries to close the window:
UGameInstance* instance = GetGameInstance();
if(instance)
{
UGameViewportClient* viewPortClient = instance->GetGameViewportClient();
if(viewPortClient)
{
viewPortClient->OnWindowCloseRequested().Bind(delegateToCall);
}
}
If delegateToCall returns true, the window will be closed afterwards, if delegateToCall returns false, the close request will be ignored.