Webbrowser Widget focus requires extra click

I am using the experimental Web Browser widget and when I use the Set Input Mode UI only blueprint node and pass in the Web Browser widget as the widget to focus it does not work. I still need to click somewhere on the browser before it receives any keyboard input.

I have tested with regular UMG text boxes and buttons on the same screen and they focus correctly, the problem is specific to the Web Browser widget.

Hello Michael,

I was able to reproduce this issue on our end I have written up a report and I have submitted it to the developers for further consideration. I have provided a link to the public tracker please feel free to use the link provided for future updates.

Link: Unreal Engine Issues and Bug Tracker (UE-53165)

Make it a great day

Any solution ?

The issue is that you are setting focus to the container of the web browser widget, not the web browser itself. It is solvable in c++ by setting the focus directly to the internal widget. Unfortunately, this widget is not exposed to the public, so you have to use GetChildren() recursively to access the internal SViewport widget which is the actual web browser.

Unfortunately, the code is something like: TSharedRef<SWidget> InternalWidget = WebBrowser->GetChildren()->GetChildAt(0)->GetChildren()->GetChildAt(1)->GetChildren()->GetChildAt(0)->GetChildren()->GetChildAt(0);

I would not advise using this code directly, but breaking up those calls and checking if the children exist. The exact path to the widget is also likely to change with engine updates. Well, probably. You can check the path yourself if you look for how SWebBrowserView is handled in the engine by SWebBrowser and how SWebBrowser is handled by SCEFWebBrowserWindow.

This approach is confirmed working.

The issue is ultimately caused because the keyboard input is processed (or not) by the container and then bubbled up to the parents, but not down to the children. It could be fixed by Epic by either forwarding focus (overriding OnFocusReceived) to the correct internal widget or by forwarding the key events there.

1 Like