Scroll Box: automatically scroll to keep my selection in view

Hey guys. I’ve got an inventory menu in UMG with a Scroll Box that I’m dynamically populating with buttons, each representing an item in my character’s inventory. The issue I’m having right now is that, because I’m using a gamepad to control my game and not a mouse with a scroll wheel, when I move my selection down my list of items, my selection goes right off the screen. I can, of course, grab my mouse and scroll the box manually to see where my selection went, but that’s obviously not going to be an option in the long run.

I found the “Set Scroll Offset” thing for the Scroll Box, and I’ve got it set up to where it sets an ever-increasing amount the more I press Down on my gamepad, and that sort of works, but it’s not conscious of my selection, so the more items I have in my inventory, the more out of sync the scrolling becomes as I move around on the list.

I’m looking for a way to tell the Scroll Box which item I have selected so that it can make sure to scroll appropriately to keep it in view at all times. Any ideas on how to do that?

I can get the number of items being displayed, and I can get which of them I have selected, so it feels like I have all the information I need, but I’ve never been a big math guy, so I’m drawing a blank as to how to use that information to make certain my selection never goes off the screen. I’m hoping someone here will be able to help me with a simple formula or something, if there isn’t an even simpler method I’m just missing.

Thanks for the help!

Hi I didn’t find the way to use inline nodes (function), so I made one. Maybe it will help you and save your time and efforts.

There’s a function called ScrollWidgetIntoView that has you pass in the widget that you want the scrollbox to display. It does what you want.

1 Like