How to always have keyboard focus on UI widgets?

I’m trying to find a way to have a bunch of widgets (mostly buttons) on the screen that the user can use the arrow keys to select and the enter key to press, while simultaneously being able to interact with the 3D scene through mouse clicks and other keys.

I have the input mode set to Game and UI, and when I click in the 3D scene (not on a widget) the widgets lose keyboard focus and you have to click on them again before you can use the arrow keys. Is there any way I can force the UI to always have keyboard focus?

I came upon this question and I’m also interested to know the answer.

This may sounds weird but set the controller for Game only instead. Setting it for UI seems to enable the mouse to input into the UI space. which is removing the focus and setting it to the clicked area on the viewport instead. It can also locks the character from operation he camera normally without left clicking. As the controller is trying to decide the inputs between the UI and game space.

Unfortunately this only seems to work until the user clicks. The user can move the camera around, but once they click the UI still loses focus.

I needed to add an OnNativeTick method in parent widget that checks for focused widget. If none is focused reset focus to defined default widget (e.g. first button in menu). You can also do it in BP.

void UBaseMenuUserWidget::NativeTick(const FGeometry& MyGeometry, float InDeltaTime) { 	Super::NativeTick(MyGeometry, InDeltaTime); APlayerController* PC = GetOwningPlayer(); if (PC && InitFocusWidget && !HasUserFocusedDescendants(PC)) {InitFocusWidget->SetUserFocus(PC);} }

Wow, this looks dirty. But from where I stand, having a hard time managing the focus correctly, this is actually a good idea.