How to get notified when checkbox is checked, the check box is from an element from list view.

I created a list view and shown it on MainWindow widget.
The UI of a single element is designed in UITemplate widget.
The data of a single element comes from Data widget.

Each element in the list view has a checkbox. How can I keep track of checked elements in MainWindow widget?

Method I tried:

Tried event dispatchers, but when I try to bind an event for that, it asks for a UITemplate object reference. I was in MainWindow widget, and created Data widget instances to be added to the list view. Couldn’t get a UITemplate reference.

You can do the bind when you spawn the instances, each instance can have an id also created when you instantiate them, or simply add them to a list and use their index

1 Like

When I add entries to list view, should I add data widget or UI widget? From many tutorials, they spawn data instances then in the UI widget on On List Item Object Set, they cast the List item object to Data class. If to do so, I won’t have any reference to the UI widget itself, so when binding the event, there is no value for “Target”. Question seems dumb, I am sorry!

The list view knows about the widgets it instantiates:

This script would live in the widget that hosts the listview itself but you can also delegate the dispatch to another actor / widget. Ensure you flag both the List View and the Checkbox (in the instantiated widget as isVariable at the very top of the details panel)

1 Like

Thanks I got the on check state change event working! But I am confused that in your BP, you get the checkbox 19 from New Widget Blueprint, then assign it to the target of “Bind Event to On Check State Changed”. I can’t do the same since the “target” requires widget, not checkbox.

I can’t do the same since the “target” requires widget, not checkbox.

This is not true; a native (as above) OnCheckStateChanged requires a checkbox ← that’s precisely what you asked about in the topic. Perhaps there’s some confusion regarding how list view works:

  • there is a user widget with a checkbox
  • there is a list view that creates those user widgets by pulling data from objects
  • when the list view instantiates the User Widget with a Checkbox, we get its checkbox and bind its delegate

If in doubt, post script. Without knowing the details of the setup, it’s hard to imagine what’s going on on your end.

1 Like

You’re right. OnCheckStateChanged does require a checkbox as target. I was confused with another event’s similar name.
Now I want to know which element called the event, as the graph shown, tries to print the name of the element containing the checkbox. But I always get the last element’s name. Is there a way to get a reference to the widget that’s calling OnCheckStateChanged? Ultimately I just wanna keep an array of checked and unchecked elements.

What you’re doing up there will not work.

Now I want to know which element called the event

  • inside the TileUITemplate, add an Event Dispatcher with any data signature that you need
  • still inside the TileUITemplate, have the onCheckStateChanged call the dispatcher you added, pipe in the state of the checkbox and any other data (you could even send a Self reference - but it seems you want a string)
  • when binding (as in your screenshot above) rather than binding to the native onCheckStateChanged, bind the event to TileUITemplate directly
1 Like

What a legend. That works. Thanks.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.