Extending a UButton? How do I make an OnClickListener callback?

An example using OnClicked, OnClicked type is FOnButtonClickedEvent:


DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnButtonClickedEvent);

It is a Delegate without parameters.

So… In your .h:


UFUNCTION()
void OnMyButtonClicked(); // No parameters here because **FOnButtonClickedEvent**

UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
UButton *MyButton;

In your .cpp:


MyButton->OnClicked.AddUniqueDynamic(this, &UMyClassName::OnMyButtonClicked);

It is the same for the others events.