Is there no way to prevent keyboard focus from being set to nothing?

I’m pulling my hair out on this nonsense. If you’ve a main menu and the Play button is focused then the player clicks on the background the Play button loses focus.

I’ve tried all the tricks of setting the widget as Visible, I’ve tried setting the Overlay as Visible, I’ve tried goofy workarounds like reacting to mouse button up which doesn’t even fire, and finally I tried OnFocusReceived which does fire but is still not ideal.

Why does UMG insist on focusing nothing! Why UMG! Why Unreal! Why are you making my life miserable. Uhg.. sorry.. UMG is.. something.

This is absolutely destroying accessibility of my game. It flat out breaks keyboard navigation because attempting to navigate after focus has been completely lost with keyboard does nothing. It doesn’t restore focus to the next available widget.

What I’ve setup is my HUD is a 3 stack system. Main menu gets pushed to the stack. Clicking Options for example then pushes the Options widget to the stack. I’ve checked on the HUD and the stack widgets and there’s no relevant settings there either for this.

All of this is utilizing CommonUI so I’m within CommonActivatableWidget.

Think I might have found a solution. So on the root widget UNCHECK “Consume Pointer Input”. Next add the OnMouseButtonUp function override to it. In that set it to focus keyboard to the Play button in my case (or GetDesiredFocusTarget, etc..). Now go through and CHECK “Consume Pointer Input” on any widget you want to block this behavior.

This seams like a janky workaround, but it’s the best I could come up with if anyone has any better ideas on how to get UMG from focusing nothing.

Ok, the below is what I’ve come up with so far. It doesn’t restore focus to previous widget, but it at least keeps focus from completely breaking.

CommonActivatableWidget

It’s important that this widget does not consume pointer inputs otherwise the mouse button up function won’t do anything. The widget should also be focusable as we’ll handle the focus target in the GetDesiredFocusTarget function.

It’s also important that Visibility be set to Visible, but in my case that’s handle automatically when this widget is added to a common widget stack.

Now the next part is to deal with widgets that should block this behavior. That automatically works for A LOT of interactable widgets such as buttons or input types. However if you want this for other widgets you should simply report back that click is already handled OR set the widget to consume pointer inputs. I preferred to just handle the click so that mouse wheel doesn’t get consumed. This is easily done with the below.

This still feels a bit like a bandaid, but at least maintains some accessibility to avoid keyboard navigation being completely lost, which is catastrophic issue if you care about accessibility of your game. Really wish Epic took UI a bit more seriously as UI has been problem after problem.