Download

Binding an event dispatcher within a foreach loop?

I’m attempting to make radio buttons. Currently, I have a list of strings that I turn into a list item (a horizontal box widget that holds a checkbox and a label), then bind a bunch of values, then add to a vertical box’s list of children. However, I have an event system semi-set up such that when each checkbox’s checked state changes, it calls an event dispatcher to let all the other checkboxes know to check and see if they are the checked box, and uncheck themselves if not. I set this binding in the event graph, after creating each individual radio button-like widget, and pulled a new delegate event off the Event pin on the Bind Event node. This filler event raises an event on the radio button widget that calls the function to perform the check and set the checked state as necessary. However, this approach only seems to work for the last radio button in the list.

I know that sounds rather confusing. Here’s the desired flow in a nicer format:

  1. A list of Radio Buttons is made. Each Radio Button consists of a horizontal box that contains a checkbox and a label. After the creation of the individual widget, all properties of the widget are set. An event (created by pulling off the Event pin on the Bind Event node) is bound to a HUD widget’s event dispatcher, then the radio button is added to a HUD widget’s vertical box of children (using the AddChild method node).

  2. When a radio button’s checkbox is checked, its CheckedStateChanged event is raised. If the supplied boolean is true (meaning the checkbox is now checked), then the HUD widget’s event dispatcher is invoked.

  3. The event dispatcher calls all the radio button’s functions to check and see if they are the box being checked, and to uncheck themselves if not.

Here’s what’s happening:
The radio buttons are being made, and they display fine in the UI. However, only the last radio button in the UI will uncheck itself when another radio button is checked. All others function like normal checkboxes. Is there a part of this process that I missed?

Oh yeah. I would submit a pic of the blueprint, but it contains sensitive material that I’ve not allowed to divulge, even in the part in question. Sorry :confused:

Hello,
without any visual, the only idea i would give to try would be to check your loops. As your issue is on the last button maybe you linked a completed instead of a loop body somewhere for example (or any other set which would be on the last in the list instead of the last selected).