Button widget and c++

image
As I know, for text widgets and the like, i can bind functions written in a C++ class (example in the picture). Is it possible to do the same, but with buttons, and if so, how?
image

in header

	UPROPERTY()
	UButton* Button;

in cpp cdo

Button = CreateDefaultSubobject<UButton>(TEXT("Button"));
Button->OnClicked.AddDynamic(this, &UMyWidget::Click);

Where UMyWidget::Click would be the click function inside of the class UMyWidget
You can ofc bind to another class if needed. I’m guessing it would be a self contained class probably derived from UUserWidget.

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.