Getting ScrollContainer to follow focus with a VButtonArray

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By royaltycomplex
:warning: Old Version Published before Godot 3 was released.

So, I’m currently trying to implement an inventory. I was able to add items to an inventory by creating a new Button and Label (to get the count of how many items of that kind there are) every time. I think using a VButtonArray would probably end up being better, considering I can get the index of the button and use that to track which item is being used by the player, plus it would make for less nodes created.

Either way, my main issue is having a scrollable list of items, without using a mouse.

There was another question asking about following focus with the ScrollContainer, but it used several children in a VBoxContainer. What I want is just one child, that being the VButtonArray (possibly more if I end up putting a few VButtonArrays in one HBoxContainer for columns).

Obviously I need to do this via script, but I can’t fathom how to go about this. I was thinking of getting the index of the currently selected/focused button and using that to determine scrolling, but I just can’t wrap my head around it right now. Does anyone have a solution?

I’ve just been playing with it for a little while and it doesn’t seem like there’s a way to follow focus. There’s no way to get an actual button from the button array. You might have to go with the VBox setup. Or check out ItemList and see if that’ll work for you.

edit: Here’s a link to help with scroll container and VBox: https://forum.godotengine.org/2199/how-to-make-a-list-with-a-scrolling-container

indicainkwell | 2016-11-04 21:44