UMG - Widgets event as parameters?

Hi,

I created a custom Button widget

image

I use a caption variable that initializes it in editor

image

question :

I want to pass another variable containing a call back/custom event for an action that would be triggered by the button

how do I do that ?

thanks for en-lighting my path

You bind it in the external blueprint:

Above: the widget’s button, when clicked, will trigger the custom event in this blueprint.


You can also create a custom dispatcher and send some data across. This way you can bind multiple buttons to the same event and use said data as a filter, as in:

I feel like we discussed this last week.

thanks

yeah something similar

but I cannot bind to on clicked since the component is complex, it’s not just a button
hence my question of passing a custom event as a parameter that would then be given to the button on clicked action

like a callback in c++

Any widget can override onMouseDown / onKeyDown. Call the event dispatcher there. Pretty much any native widgets can be interacted with / have focus. No buttons needed, indeed. Buttons often get in the way, actually.

Every time you do something to a widget, a piece (however many registered) of code gets a notification.

Other than that, I don’t understand what kind of callback you’re after.


but I cannot bind to on clicked since the component is complex, it’s not just a button

I hope you understand my confusion :slight_smile:

the idea is that I’ll re use that component many times, so in its parent widget I need to just bind a different function/event/callback whatever so that each button click triggers a different functionality

it’s just a game menu, but I don’t use a plain button component, it’s embedded as the image I posted

so the button onclicked is there, but I should launch a different event from there

if I select my custom widget, there are no mousedown event on it

so far I have set the event inside the component but it’s obviously not what I want

the event itself must be set in the parent component (the menu) with a different event for each button widget

[edit] pretty sure I have to use dispatchers in this case

The overrides are inside the widget. But I think I know what you need now.


If you want this Event List populated, you use an Event Dispatcher:

This is sometimes referred to as autobind - not sure if that’s the correct term. The above is using a single dispatcher for all buttons. If you want multiple unique events, add more dispatchers:

image

1 Like

I dont understad, where do I add the event dispatcher in the parent ?
cos I dont get any green button

1 Like

well still dont work for me
I dont see the link between the dispatcher end the push button

…unreal too, clicking on the button just does nothing

I cannot acces onclicks of each buttons from the main menu widget

image

ok my bad I missed