Clicking changes focus from widget to viewport


I’m trying to create a menu that can be navigated through keyboard/controller only.

Right now, the issue I’m running into is the menu widget losses focus if there’s a click input from the mouse. It doesn’t seem to matter if the mouse has been captured, hidden, or if an input mode is specified. Steps to reproduce:

Create empty level

Create widget blueprint

Add button to widget

Display widget in level (as per LevelBlueprint.png the button will have focus from the keyboard)

Launch game in New Editor Window

Following these steps gets the button focused and responds to keyboard input, which can be verified by using the Widget Reflector (Window → Developer Tools → Widget Reflector, then check “Show Focus”) but once the viewport has been clicked the keyboard will lose focus (BeforeClick.png and AfterClick.png).

I’ve tried just about every solution I can find to no avail. The closest I’ve come to resolving the issue was through the very similar post [bug] losing focus when clicking in level view - UI - Unreal Engine Forums

The conclusion in that answer section was:

“I made a blueprint exposed function that looksup the currently focused widget and sets a focus reply event. I called it keepfocushandled which returns an event reply for the mouse down event. This works fine, although this solves my mouse click issues i found thst keyboard navigation can also cause the viewport to receive focus. It would be great if you guys would show an umg example which supports keyboard, gamepad and mouse navigation.”

I’m uncertain as to how you can look up the currently focused widget however. I’m at a loss.

Any help would be greatly appreciated!

I am having a similar problem and I have not found a resolution to this yet. Anyone out there have an idea?

Got same problem, my most blunt solution so far is:


Getting the player controller and setting focus on tick seems pretty expensive.

I have the exact same problem… Please, we need help !!! lol

My menu support Keyboard, Mouse an gamepad very well.

I copy the text of my answer I wrote here :


I give my solution, I hope it will help you (and the other people who come to this forum and were looking for the solution like me, 30 minutes ago, before I found this little trick! ^^)

1- record the focused button in the Event Tick

2- Create a giant, invisible button, without pressed padding, which contains the entire menu.

3- When clicking on this giant invisible button (OnPress, not OnClick), set the focus to the current focused button

It works perfectly for me! ^^
Final result:

Tip: you can remove the default dotted frame around the button by disabling this feature in project settings: