ListView Item Click not working

I have a simple listview with buttons as items. But my ItemClicked event not firing even though onhovered event firing. Any ideas why ? Not : Using 4.25

1 Like

The Button handles the click, so the widget is never informed that it was clicked, so the listview does not know about it.
Either don’t use a button, or make your own on clicked solution by having a dispatcher in the entry widget, that is called when the button is clicked. Bind to it during the Item Initialized/generated event.


I think even before what ste1nar said, the issue is: you are casting to the wrong thing.

The “Item” output on the OnItemClicked isn’t the widget, it’s the *item *that your widget is representing in the list view. If your list view is representing actors, you need to cast to “actor”, etc.

When you add the item to list view, what is the class of the object you’re adding as item? That’s what you should be casting to.

If you haven’t read this forum post, I highly recommend:…-started-in-bp

Quite long, but it explains *a lot *about ListView and TreeView. ListView widgets are not the most obvious thing unfortunately, but the item-based instead of widget-based way it’s built is actually quite convenient once you get used to it.

**However, first and foremost, try to see if the ListView is actually what you need. **If you need a list of where *each widget is linked to a specific entity, *then use list view. If you just need a list of widgets without any relationship to something else, just use a ScrollBox that has a VerticalBox or HorizontalBox, and put your widgets into those. That way you can not worry about the whole item to widget link.

1 Like

Thank you very much for your replies

Hi. I was having the same issue. Here is how I solved it (The script is inside List Entry Widget)

Hi, didn’t see your script. Could you please repost it? Thanks.

I know this post is a few years old but could you elaborate on this? I always have trouble with dispatchers and I would appreciate a visual representation of your explanation if possible! I have a tile view set up and a button in my entry widget class.
Now I also found the selection mode in the tile view settings and I am now wondering how the items in the list would change visually when it is toggled on or off? It is not communicating with the button inside the entry class so where would I even set that up?

This whole tile/list view setup has been really confusing to me and I wish there were more advanced guides out there :smiley:

Here, when the entry widget is generated, bind to the dispatcher.
Clicking the button calls the dispatcher and provides the Item.
So far, the Listview is unaware anything has happened, so use the function of the Listview to set the selection. Now all the relevant events associated with the Listview will execute.

For selecting multiple things, you’d use the “Set Item Selection” function instead, which has a bool input. Check if the item is selected with “Get Selected Items” and query if the Item is in the list if Items.

I hope this helps, because it’s the simplest way I can think of.

A note on the Selection Mode of the Listview is that I’m not sure it’s of relevance what option you have selected and I don’t know if they work properly.
That’s because I think it is mostly linked to user input- as in clicking on the widget-,where as through scripting, even if single is selected, multiple items can still be selected. And you’re not using the Listviews input behaviour if you are using a Button.

1 Like

Not sure if the above post actually replied to you or not so trying again…

1 Like

Oh yes, your reply worked. I haven’t checked in here for a while thinking no one would reply to this ancient post, haha. This was incredibly helpful thank you!!