Switch Between input mods only with C++

From the cpp file of widgetBlueprintLibrary

// pick only one of the the following

// game and ui
FInputModeGameAndUI InputMode;
// game only
FInputModeGameOnly InputMode;
// ui only
FInputModeUIOnly InputMode;

PlayerController->SetInputMode(InputMode); // PlayerController = APlayerController

extra settings for widget focus and mouse

// passed in parameters of type
UWidget*  inWidgetToFocus;
EMouseLockMode InMouseLockMode;
bool bHideCursorDuringCapture;


InputMode.SetLockMouseToViewportBehavior(InMouseLockMode);
InputMode.SetHideCursorDuringCapture(bHideCursorDuringCapture);
	if (InWidgetToFocus != nullptr)
	{
		InputMode.SetWidgetToFocus(InWidgetToFocus->TakeWidget());
	}