World Widget Interaction Problem with buttons in Unreal engine 5.1

I’m running into the same issue after upgrading to 5.1. My widget component window is set not to receive focus.

I found this on Unreal Slackers Discord

c++: FSlateApplication::Get().SetAllUserFocusToGameViewport();
blueprint: Set Focus to Game Viewport | Unreal Engine Documentation

My code to click is:

const FKey LeftMouseButtonKey = FKey(EKeys::LeftMouseButton);
PressPointerKey(LeftMouseButtonKey);
ReleasePointerKey(LeftMouseButtonKey);
FSlateApplication::Get().SetAllUserFocusToGameViewport();

and it seems to work as before now.

2 Likes