UI Widget key events OnKeyDown/OnKeyUp not generated

I have upgraded my project from 4.10 to 4.11. I used to have a key to show the menu. It calls SetInputModeUIOnly. So at that moment I can’t use the key any more to leave the UI. So in the PlayerController my overlay widget uses the function override OnKeyDown to intercept the same key and then leave the UI. now this does not work any more since 4.11.

I can only enter the UI, but no event is triggered (I set a breakpoint in the function) when I press a key to leave it. It still works in the 4.10 version.

2 Likes

It seems as it has to do with keyboard focus. When I first press a button on the interface and release it outside the button, so that at least 1 button has focus, then the keyboard control works. But otherwise not. In my load sequence EventGraph I already call “SetKeyboardFocus” on the widget, but apparently without effect.

1 Like

In the release notes of 4.11 I read this: “UserWidgets are no longer Focusable by default. Existing UserWidgets should be unaffected.”
This probably is my problem.

Its a good fix from them though, its very annoying that they were focusable by default. I added quite some debug code to detect such mistakes from myself.

Yes my problem is solved by making my widgets Focusable again. This option is in the root of the widget. Then go to the details pane and under the tab “Interaction” check the box: “Is Focusable”. My UI works by calling setKeyboardFocus when a page is loaded. The page itself than intercepts the OnFocusReceived and sets the KeyboardFocus to its first button. So then every time a page is shown, you can navigate it with the keyboard. But since the page did not receive focus any more, nothing received focus and keyboard navigation did not work.

6 Likes

I don’t understand what the problem is. The way I use it, it is very convenient. I can navigate with joystick or keyboard now.

Thank you !!
You just saved me 2 days of frustration!! :slight_smile:

I found also that setting visibility to visible for the root UI widget is a requirement for receiving input events in blueprint. Not sure if it is a change for 4.13 or not though. Setting keyboard focus wasn’t necessary. IsFocusable and default visibility state was the key to activate the event receiving.

iloveyouman

Thanks … saved me a lot of time and headache :slight_smile:

I wanted to just point out that I figured out that it’s also important that SetKeyboardFocus runs AFTER adding the widget to the viewport. It took me a long time to detect that this was my error.