How to use UListViewBase::OnEntryWidgetGenerated() and ListViewBase::OnEntryWidgetReleased()

Hello, I’m trying to add a UListView to a menu and add delegates to the list tiems. So I’m trying to use UListViewBase::OnEntryWidgetGenerated() and ListViewBase::OnEntryWidgetReleased().

FOnListEntryGenerated and FOnEntryWidgetReleased have a “UUserWidget&” reference input parameter, and I can’t find any binding that compiles to that.

For example, if I write:

void OnEntryWidgetGeneratedCallback(UUserWidget& InListEntry);

mListView->OnEntryWidgetGenerated().AddUFunction(this, FName(TEXT("OnEntryWidgetGeneratedCallback"));

Then I get an “error : Missing ‘*’ in Expected a pointer type” at the declaration of OnEntryWidgetGeneratedCallback.

If I write:

void OnEntryWidgetGeneratedCallback(UUserWidget* InListEntry);

Then I get an “error C2665: ‘TTuple::TTuple’: none of the 2 overloads could convert all the argument types”

Any suggestions? Thanks!

I think, if I’m not mistaken, you are trying to bind a delegate (that takes a parameter) to your callback, which correctly also works with the same parameter, but without actually providing a… parameter :wink:

So after the FName, add (as a second argument to the AddUFunction function) the reference of your UUserWidget. If you have it as a pointer, then dereference it. Makes sense?

Actually, it doesn’t make sense. The menu that contains the ListView can’t know which UUserWidget was created - that’s the point of having to use mListView->OnEntryWidgetGenerated().

On the contrary, UListViewBase::HandleAnnounceGeneratedEntries() calls “OnEntryWidgetGenerated().Broadcast(*EntryWidget);”. And I’m trying to capture that from the menu that contains the ListView.