Inventory System Problem with Gamepad Focus

Hi, Im currently rebuilding an Inventory System by Ryan Laley on YT and i wanted to make my Inventory Interactable via Gamepad. everything is working pretty well except for this one little thing thats making me crazy.
So if i have multiple Items in my inventory and press the gamepad direction key to the right it then the second Item gets focussed. as if the first one was focussed but needed a wake up to work. Then everything works fine.

Problem is now when i only have ONE item in my inventory or in a container gameobject it cant be focussed or pressed or anything. the only way to get this working is to press TAB on the keyboard. Then it is focusable and pressable BUT i dont want to press TAB on a Keyboard when im playing on a gamepad. Maybe someone please have a fix for that , im loosing my mind :smiley:

Hey @High_Reso1, welcome to the Unreal Engine community!

Have you tried adding a set focus node after creating the widget? This may prevent needing to interact with the widget once before it comes into focus. If that does not work, can you share a screenshot of how you are creating the widget?

Please let me know if this works for you, and good luck!

Hey @anon78826165,
Yes i have tried the set focus node in the event construct and in the tick event recently. both didnt set focus on the button

Create Slots from my inventory into the inventory windows grid:

try set focus if inventory grid has any children:

i guess Set Focus/Keyboard Focus/User Focus is not the same as “Gamepad” Focus (with dotted lines) because if i set Focus to any button “On Hovered” its not getting interactable via gamepad but in a scroll box instantly scrolls to the button ( because i set “scroll when focus changes” to instant / animated
it could be that the Child Widget (Item Slot) that gets added to the Grid gets Focus but not the Button Element inside of each Item Slot.

So i will write a solution to my own problem now :smiley:
Problem is that i focus the WIDGET and not the BUTTON INSIDE the widget.
i made a screenshot with explanation for anyone that has the same problem
easy fix but much headaches!


The easiest solution is, to set the Focusable Switch of the Widget to false, and only make the Slots focusable.
This prevents the Game from giving the Widget itself focus anyway…
The next is, that you delay the construct… Don’t do that… It is not important.

What you want to do is, to Force a Prepass here… So the Widgets Contents get a wake up call.

I would recomment not to do this stuff in the construct anyways… Ryan is doing some of that… yes… But it makes more problems later, especially when it comes to updates of slots in a dragdrop operation… I’ve done his Tuts around 20 times… And build my own system with the knowledge of Errors, Problems and Solutions i learned of that time…

So… Here are my Top 3 Tier List of “Things to not do like Ryan”:
1st: Splitting Structs.
Never ever in the Future do Struct Splitting!! It’s the Devil or worse!! Always use Breaks!
You can still split Vectors and such… But not custom made Structs…!
The Reason is, that the Reflection of a split on a struct can not be updated properly. I dunno why… Perhaps it is caused of shifting of the pink or such…
If you update a strict later… The split won’t update correctly… And you get a hell ton of errors to fix those splits…
So… Breaks are of no problem here… Do Breaks!!

2nd: Push all Widget initialisation into Construct.
You can push setText, setValue and such there… But step away from doing reference, cast and other stuff via the Construct Event. Always create a Custom Event or Function, that you can call when it really is needed! This prevents of Ref and cast errors, caused by not valid objects.

3rd: Keeps it as it is.
On my 3rd run of his tuts, i realized that many things he is doing, are just a waste of memory, operations or performance.
Yes… Really… He is very very skilled… But that doesn’t mean you can’t do things better. His Tuts are just a Hint on how to start… Not the ready Procuct.

The Reason to catch those Tuts is not to copy them 1:1 to your Project, but to learn how one guy is doing this for his one Situation and Needings.

To the Problem:
When toggling an Inventory to be visible, you set the Game Input Mode to UI. That’s OK.
You really should set the first slot of this inventory as “In Widget to Focus”.
This will automatically set the first slot as focused to interact with it via Gamepad.

If you followed Ryan’s Tuts, the way to get the first slot is simply:
Get Inventory Component > Get Inventory Widget > Get Grid Box > get children > first > get widget

1 Like

Hey @BDC_Patrick thank your for your comment,
so setting the widget to non focusable didnt work before i was doing that fix i showed on the screenshot. it only gave me errors. now after the fix i can set it to non focusable but it does not matter anymore because the focus is set correctly now.

The thing with the delay you are right i tested again and i can now delete the node and its still working.

Thanks for the advice :+1:

  1. i think i did everything with breaks , not splitting because i think it looks cleaner, too. if i need just one variable i can also collapse the break note afterwards.
  2. ok, but i think in my case i need to do casting in the construct. i dont see why making an event or function out of it would make any difference. But please correct me! im just starting to learn that stuff. i would have never thought a inventory would be so difficult to make :smiley:
  3. yeah, i have a concept of the inventory that i want to make in mind and only use or add what i need for that. sometimes i realize that stuff he was doing actually is important for other stuff i need later:D but thats the way it is i guess

and lastly yes but my problem was that i was getting the widget like in the Tutorial but i needed to get the button inside the widget. i did not find an option that said “In Widget to Focus” that would have saved me a lot of time

1 Like