Event in Custom UserWidget

Hi,

I have a custom UUserWidget derived class where i want to have an Event that triggers when a method is called.



DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnMenuToggleEvent);

....

UPROPERTY(BlueprintAssignable, Category = "Event")
FOnMenuToggleEvent OnOpened;


However the event is not visible in the blueprint of the custom UserWidget.
Am I doing something wrong or is it not possible to have a dynamic multicast delegate in a UUserWidget?

Hope somebody knows what’s wrong :slight_smile:

Should work fine. You need to add BlueprintCallable if you also want to be able to fire that event in Blueprint.

Oh and make sure you actually reparented the Widget to your custom class to.

hey maybe i should have explained myself a little better:
i have a



DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnMenuToggleEvent);

UMenu : public UUserWidget

UPROPERTY(BlueprintAssignable, Category = "Event")
FOnMenuToggleEvent OnOpened;


when i create a blueprint class of UMenu, it does not show the OnOpened event on the right in the blueprint details as it would for example show an OnClicked in the UBbutton details
i dont want to fire the event from the blueprint, i just want to assign it in the blueprint

How are you creating that class? Are you creating a new Widget then re-parenting it?

i am creating it in the editor, by creating a new blueprint class and then selecting “UMenu”

Yeah that won’t work then, you need to create a new Widget Blueprint (User Interface > Widget Blueprint), then reparent it (file > reparent blueprint) to you custom class.

Widgets are the only class you need to do this with, as creating it as a normal blueprint doesn’t let you use the UMG editor either.

that did not solve the problem:

e5cf14caf2e27d075422e5b3430f4f3734a4002f.jpeg

also i dont think theres a difference with creating a new widget blueprint and then reparenting it or simply creating it like i said (as shown in the next picture)

bc194746ccc560e77815423dffd455153e44e09f.jpeg

The events don’t appear there on the CDO - you just hook them on the blueprint graph normally if you’re inside the class declaring them. Events only shows up in the details panel if you’re instancing this widget on another widget blueprint.

Normally the pattern is to have a multicast delegate for external folks, and to make a function that’s a BlueprintImplementableEvent that a subclassed BP can override.

ahh i totally forgot about BlueprintImplementableEvent!
thanks alot, now everything works just fine :slight_smile: