Binding an event to a button WITH AN EVENT INPUT

Hello all, I have what seems like a simple problem that I cannot find an answer to. As part of an editor utility widget BP, I am creating buttons by calling “Construct button” and then binding events to them.


The problem is, this is part of a loop which generates multiple buttons. I don’t mind binding all the constructed buttons to the same event, but I have no way of knowing WHICH button is calling the event when clicked, thus getting unique functionality per button is impossible. I really need a way to pass an INPUT to the event (like for example, what number button was pressed) and set that up with the binding. However, unreal won’t let me do this. If I add any inputs to the event, I can no longer wire it to the “bind event” node - it shows the error “delegate is not compatible with delegate by ref.” So - is there no way to bind an event to a button and also pass some sort of unique input to that event?

Sounds about right.

Instead of using native buttons, wrap this button in a widget and create those dynamically. Each wrapped button can now have an ID or send some data via an Event Dispatcher - the inputs you mentioned. You can even send a self reference - the entire clicked widget in case you can’t be bothered to hook up data to dispatchers.


This would also allow you to do some pre-processing inside the button; perhaps there’s no need for “unique input to that event” and the button can send pertinent data - like a texture, component or asset - anything really.

1 Like

Thankyou for the fast reply. So I am now constructing my button-wrapper-widget (instead of just a native button) but I can’t seem to access any variables or parameters of the widget from the constructing BP. Annoyingly, the only one I have access to is the “Button” parameter itself, so I am in the exact same position. Is there some way to get/set a variable in the wrapper widget?

  • if this was the wrapped button:

  • you could add and bind a bunch of them like so:


The int is just an example, not sure what data you need but you can hook up pretty much anything you desire.

4 Likes

I got it working thanks to you. I was using ‘construct’ node instead of ‘create’ which allows you to set inner variables.

2 Likes