[solved]
I got it.
In case someone is interested:
void
AMyGameGameMode::allowInputUiOnly(UUserWidget* pWidget)
{
FInputModeUIOnly inputMode;
inputMode.SetWidgetToFocus(pWidget->GetCachedWidget() );
APlayerController* pPc = GetWorld()->GetFirstPlayerController();
pPc->SetInputMode(inputMode);
}
void
AMyGameGameMode::allowInputGameOnly()
{
FInputModeGameOnly inputMode;
APlayerController* pPc = GetWorld()->GetFirstPlayerController();
pPc->SetInputMode(inputMode);
}
void
AMyGameGameMode::allowInputGameAndUi()
{
FInputModeGameAndUI inputMode;
inputMode.SetLockMouseToViewport(false);
inputMode.SetWidgetToFocus(nullptr);
APlayerController* pPc = GetWorld()->GetFirstPlayerController();
pPc->SetInputMode(inputMode);
FSlateApplication::Get().SetUserFocusToGameViewport(0);
}
It is important to call only one of these in a short time.
If you have code which calls first one of the above methods and then another one, chances are, it will not work. Clean your code.
I do only use allowInputUiOnly and allowInputGameAndUi, because I don’t like that allowInputGameOnly holds the cursor hostage inside the game window.