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).
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.
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.
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***.
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-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:
UE54 - In the Widget for a editable Text Box.
Type Focus in the properties, scroll all the way down
Uncehck all the boxes and set Virtual Keyboard Trigger to On All Focus Events