Losing focus in UI when clicking with the mouse

Hello everyone, I’m currently doing a menu for my game, and the menu should be navigable with the mouse, controller, and keyboard. If I click outside of the button with my mouse, the focus is lost, and the keyboard and the Controller don’t work anymore. I tried the visibility and input mode only UI trick, but it does not seem to work now ( I saw another recent video with the guy saying that he could not make that work too). I tested other ways of doing that, but they are not clean and do not satisfy me. (I tested the hidden button trick, but I don’t like going back each time to the first button.)

Any solution?

You need to keep track of the last selected button as ref in a variable when using keyboard/controller.
Such that when focus is lost for whatever reason, re pressing arrow keys on keyboard or controller will re select+focus the previously selected button.
Or Any Key > Focus first button menu to simplify also.
Not sure if there AnyKey on controller(could be on cpp).

Here an example:

So I tried this a bit, but I can’t get the input to work inside the widget except with the override key down. I’d like to use the EnhancedInputAction system, but for it to work, I need to do all kinds of manipulation on my project, adding the common UI plugins. It looks a bit overkill just for this. any idea?

For anyone ever coming to this post in search of a solution, here is a roundabout solution of how to do it. My solution makes it so the selected button is always colored( you could change the style all the same), even if you click outside the button and maintain your click (it was decoloring the selected button before for me), and when you stop clicking outside, it refocuses on the currently selected button thanks to a Background button.
I hope this will help someone!