set focus to dynamic buttons in inventar

Hello…
I’m trying to get the focus on a (list of) button(s) inside a umg widget (an inventory widget in this case), so I can use a gamepad/keyboard to “click” it and move up and down inside the list.
Clicking it with a mouse works.
The problem is, the buttons are created dynamically based on the items the player picks up.
So the button is not really inside the inventory widget, but inside another widget (called inventory buttons widget).
I have a button to close some stuff inside the inventory widget, this one I can set focus to.
But I fail at getting the focus to the inventory buttons.
I tried to make an array of all the buttons created and then always set the focus to the last index of that array.
This kinda works in terms that i can set the dotted line to those buttons, but i can’t use the enter key to select them. I guess the focus isn’t really on the buttons, because the dotted line I get through that, fills the whole space horizontaly, but if i click on the button with a mouse, the dotted line is only around the button (because I didnt set it to fill for now, for testing purposes). I guess I’m putting the wrong stuff into the array, for my purpose?

my setup:
the inventory buttons widget

the inventory widget (graph)

the inventory widget (designer)

and the player blueprint, where i want the focus to be set on the buttons, when i open the inventory

I tried to get my head around it for the last couple of days, the last thing I came up with was that array with the created buttons, but I dont know if that goes into the right direction. With this I can sort of highlight the buttons, even use the cursor keys to move up and down the list, but I can’t select them.
So, does someone has any idea of how to get this working? Thanks and have a nice weekend.

in a futile attempt I changed the way the buttons are set up inside the inventory widget. so they get added as child from the array (i put them in after they were created) and not from create widget.

but I still can’t get the focus to work on ‘em. I made some print string stuff, and when I hover over them with the mouse every button has a unique name n number that, when i click the button, corresponds with the output log of button pressed. and after i clicked em once with the mouse i can hit enter on the keyboard to press the button. but then i can’t use the up/down keys anymore. also when i enter the inventory, one button has the dotted line, but i cant use enter, but i can use up/down keys. when i press tab once, i can hit enter on the button, but not use the up/down keys.
seriously, what am i missing? i don’t get it, it’s drivin’ me nuts.
any ideas?

nice, figured it out.
technically I was trying to focus on the widget and not the button that’s inside the widget.
for me it was obvious what I wanted to do, set the focus on the button, but I should have told the engine
that as well :wink:
so, here’s the solution.

out from the created widget I got the button, set that to a variable, so I could get it from the inventory widget
when setting the focus inside the player bp. and it works :slight_smile:

1 Like