ListView OnItemSelectionChanged fires multiple times when scrolling

Hi SasMaster

I think I see two separate issues, I hope I can help with both!

So we are on the same page:

ListView: A list based on around Items, and widgets that are used to visually represent them

Item: An object. Does not know it is an Item. Can be literally any unrelated object you want I believe. e.g. StaticMeshActor, Pawn, Material Instance etc.

Entry: A Widget used to visually represent an Item. Does not know the Item it represents

After one item selected, scrolling makes some new entries appear selected

(I find it very easy to mistake usage of Entry and Item, so I typed them in bold to help with clarity)

On initial construction, a ListView will construct the minimum amount of Entries necessary to fill the visible area of the scroll space. When an Item scrolls out of view it’s Entry widget is “released” not destroyed, then when an Item needs to come into view, one of the released Entry widgets gets re-used to represent it.

So, what could be happening is you click an Item, selecting it, your Entry widget then changes it’s visuals to show this change. You scroll that Item out of view, the Entry widget gets released, then since a new Item is scrolled into view, it gets assigned to represent it. So you have the same Entry widget now representing a different Item further down the list, showing the visuals of it being selected (but the Item itself actually isn’t selected).

What you can use to regulate this is OnEntryInitialized (In the widget that has the ListView). It fires when an Item comes into view (and also items that start off already in view initially).

Your setup could look something like this ^

OnItemSelectionChanged Multiple Firings after 1 selection

I don’t seem to be getting the same behavior here, I find that OnItemSelectionChanged (Entry Widget) only fires when:

-In view and item it represents is selected/unselected

-Assigned to the already selected item (when the selected item scrolls back into view)

OnItemSelectionChanged (List view) Only fires when an Item in view is clicked.

Let me know if you still experience behavior different to this, once solving the other issue with multiple items appearing selected.
Just comment with further details of your code setup and I’ll see what I can do :slight_smile:

Hope this all helps :slight_smile:

6 Likes