Keyboard and gamepad navigation in scroll box

Hello,

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:

  1. Make a scroll box containing a few vertical boxes.
  2. Add buttons to all vertical boxes.
  3. 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!

1 Like

This problem still exist. Does anyone have a solution for this?

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).

We are looking for an answer on this one as well.

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!

Code position: SScrollBox::OnNavigation

1 Like

It’s 6 years later on UE5.1.1.

We have Nanite but not this.

Widget navigation (arrow keys) unreliable? - #15 by Roy_Wierer.Seda145

1 Like

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.

1 Like

Hi! I found the solution: Just Set Navigation Destination to CENTER.
image