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

I’m not sure how an OnClickListener is supposed to be implemented here as all I see in the docs UButton | Unreal Engine Documentation
is the IsPressed() function how does this work?

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.

That is a lot simpler than I thought it would be. Thank you very much. Don’t think I could have figured it out too quickly without this.