[UMG] Set user focus doesn't work

Hello everyone,
I’m trying to set the focus on a widget to catch input events (through the override of OnKeyDown) unfortunately setting the focus doesn’t work (and consequently catching input).

That’s how replicate the bug:

It will not print anything.

Hello Maggese,

If you target a widget that is focusable and has this option set to true(a button for example), this setup should return true. I hope that this information helps.

Make it a great day

1 Like

Thank you for your reply.
That’s exactly the problem: it doesn’t return true. Never.
The widget I’m using has only text though. Is this the cause?

If you take a look at the details for the button widget you will notice that it has an Is Focusable option whereas the text widget does not. If you create a new widget that contains only the text and you then bring that new widget into the widget that you are currently using via the user created section. You will then be able to set Is Focusable. This may be a viable workaround depending on your needs.

1 Like

This “bug” is still pretty annoying and remains in 4.25. Even though you can set individual buttons and elements to be focusable, you can never actually set the user focus to them. You have to create separate widgets for each button. Annoying as f***.

1 Like

I’m inclined to agree… there is a C++ solution (set bIsFocusable to true), but as usual with Unreal no pure Blueprint option, even though UMG can be made to work with 100% blueprints.

As a workaround, you can however create a Blueprint interface for UserWidget with something like a FocusOption function, and then make sure you have a button inside your UserWidget somewhere and point the SetFocus node to that button inside of your FocusOption interface function, so if you then call that interface function after you added your widgets to the viewport, that will work.

I recently learned that you can confirm it using the Render Focus Rule debugging option in the project settings.

1 Like

Here is how you do it:

1-Make sure your widget that contains the EditableInputText has bIsFocusable to true
2-Use: SetUserFocus to the InputTextBox as target, and “GetOwningPlayer” as the controller
3-Use: SetKeyboardFocus to the InputTextBox as target.
Example:

1 Like