I’ve been trying to find a solution for being able to have proper keyboard navigation using a scroll box.
In the current state, the scroll box only supports the simplest way of navigation.
From the moment nested focusable widgets are involved, the implementation completely breaks.
A simple example:
Make a scroll box containing a few vertical boxes.
Add buttons to all vertical boxes.
Press play and notice you can’t navigate between the buttons in the vertical box
Expected result: You would navigate between the buttons and when reaching the end, the scroll box should scroll
Actual result: The logic in OnNavigation fails that results in not being to navigate any further than what is visible on screen.
This happens not only using vertical/horizontal boxes. Whenever focusable objects are one level deeper than the direct children of the scroll box, it fails to navigate.
In the OnNavigation method in SScrollBox.cpp, it iterates through the children until it finds something focusable and focuses that. Because horizontal boxes are not focusable, the keyboard focus gets destroyed.
It should instead do a recursive search within the children but after experimenting with this, it wasn’t a good solution.
Does anyone have experience with this or found a way to get around this?
Thanks!
The worst part is, that it already completely breaks when you use a WrapBox inside the ScrollBox (The most common scenario in any game: Navigating a list of items).
I am also looking for a solution to this problem in 4.21.1.
Even explicit navigation rule pointing to elements within a ScrollBox are not recognized. A workaround or fix for this issue would be greatly appreciated.
I had some success calling ScrollWidgetIntoView on the scrollbox when the focused widget receives focus on navigation. I’m also using a higher NavigationScrollPadding on the scrollbox. If the element received focus via a mouse click I don’t call ScrollWidgetIntoView, only calling it if the focus came from a keyboard or gamepad navigation.
We also use ScrollWidgetIntoView but have to use the Center mode, because unreal is not able to navigate to elements outside the view. With Center you guarantee that the element above and below is in the view and can be navigated to.
Guys, try to put those ScrollBox’s contents into one VerticalBox(or other container box), make sure ScrollBox only has 1 child, then you can put your contents in that child, the navigation works fine inside the ScrollBox. Hope this help!
Not sure if this will help anyone, but I wound up on this topic because I couldn’t even get keyboard controls to navigate a Scrollbox + Wrapbox
and this was amongst the only things that came up in my search results, which is why I’m posting this here in case what I found helps other people who are doing the same searches.
What wound up working for me was changing “scroll when focus changes” setting on the scrollbox. Which appears* at least in my novice level testing to get both keyboard && gamepad navigation working with wrapboxes nested inside scrollboxes.