I’m trying to bind a text field to a struct member. The structs are in an array called Inventory, and I want to display the fields for each item in the array (like price, number, etc.). However, I get only the default properties on screen.
What is the right way to do this?
hi there,
where do you set your struct to a specific InventoryItem to read data from?
Hi ,
Obviously, this is the problem. However, I’m not sure where to set it.
hmm, ok.
So there is an actor which will probably has an inventory and so he has inventoryitems right? You mentioned an array in your first post.
Which actor is this?
Then you have your widget, which should probably display those items on screen.
Now you need to create a communication between your array and your widget.
To help you out i need to know the location(BP) of:
- your item array
- the BP which creates the widget and holds its referenece
Hi again,
I don’t have an actor as this is UI for an in-game auction. Anyway, I have 2 BPs:
- InventoryWidget, which stores the array and displays the items on screen.
- InventoryItemHorizontalBox, which contains the fields that are displayed (price, number, etc).
There’s a loop in the first widget that creates a new InventoryItemHorizontalBox for each struct in the array and adds it as a child.
I guess I have to set the ItemData variable after creating the item and before adding it to the array?
hey, there needs to be at least one instance which creates your widget 
It’s created on button click 
Here are the graphs:
I tried to set ItemData in the second graph.
Edit: I think it is set correctly. The problem is I can’t access it in the other widget (in which the binding is done). It needs a reference to the first widget, and when I create one, the compiler says access none.
It seems i misunderstood your doing.
you already have the reference, you just dont use it.
See inside the first picture where you create your horizontal widget? that output pin is the reference you´ll need. (the one which you set to the add child node)
btw. your add to viewport is obsolete, since you add it to a widget which is already on screen (besides you add “nothing” to the viewport like this at all, except the widget which you are in already and which is probably already visible).
So simply create a function inside your HorizontalBox called f.e. “SetItem” with an input of your ItemClass/Struct.
Then inside your OnClicked, after create widget take the output reference and call “Set Item” give it the item from your foreach loop.
Now your Horizontal widget gets the desired data it needs and you can bind them.
, thanks a million for your help. Now it works as expected.
I have another problem however - the Add to Array function (in the second picture) does not seem to add an item to the array correctly, that is, it adds an item with default values. Do you have any idea how to fix this? I read somewhere about setting the members in the Construction script.
hey there thanks 
well, considering your last picture you can just use the Make …Struct node, this should give you the opportunity to modify its members and the result is an item (output) which you can
add to your array, however… this becomes unhandy when you want to create more items… you would need to do that multiple times.
since you have an input in Add to Array use that item reference and connect it directly to the Add Node, delete the saving and the stuct nodes.
Now prepare a sepparate area where you create some items, like mentioned.