This post is intended to be a quick-start guide to get List View up and running with simple add, edit, and remove functionality. For more advanced stuff, you may have to find another forum post to help with that.
None of this will be groundbreaking information, it’s mostly information that me, from 2 weeks ago, would’ve liked to have as a reference when first getting into all of this.
This only applies to List View and Tile View
I have not experimented with Tree View, but maybe I’ll try working with it in the future.
First, we need to create a few things:
- Our widgets (ListEntry & List View)
- Our data (Structure_Example)
- Our data representation (Object_Example)
The Object_Example is what we will be adding to our list to carry the data we want to be shown in the widget
Populate your structure with data you want to show in the list entry,
then add it as a variable to our object.
Remember to check Instance Editable & Expose on Spawn so we have an exposed pin on the Construct Object from Class when the time comes.
Let’s move on to the List Entry
We need to add the UserObjectListEntry interface to the list entry for it to be usable.
Implement the event On List Item Object Set in the list entry,
then we can cast to our object and save it as a variable.
It’s very important to only save the Object_Example variable and NOT the Structure_Example_Var variable.
If the list entry widget referenced the Structure_Example_Var as a separate variable, it won’t update values beyond the initialization unless we manually call Regenerate All Entries.
But as long as we bind the widget elements from the Object_Example variable, the widget will update automatically.
Let’s move to the List View
Because we added the UserObjectListEntry interface to the list entry, it’s now available in the entry widget class of the list view.
Now we can add the list view widget to the viewport and start adding objects to it!
I’ll be working in a Player Controller blueprint to add, edit, and remove list entries since I have a reference to the list view variable there already. However, this may need to be done differently depending on how you already have your blueprints set up.
Add an Entry to the List View
Construct Object_Example and set its Structure_Example_Var variable, add it to an array to reference later, then add it to the list view widget.
Edit an Entry in the List View
We get from our array of objects and Set Members in the object’s structure variable. This updates the list entry without the need to refresh the entire list.
Remove an Entry from the List View
We get from our array of objects and remove the object from the list view, then we remove the object from our array.
And there we have it!
A functioning list view that can add, edit, and remove entries.
If there’s anything major that I missed, I hope that you let me know.