I am working on a UI menu using Unreal Engine 4 and C++. I have this code (taken from this thread):
H:
UPROPERTY(meta = (BindWidget)) UButton* TestButton;
UFUNCTION() void OnClick();
CPP:
void UWidgetClassName::NativeConstruct()
{
Super::NativeConstruct();
if (!TestButton->OnClicked.IsBound()) TestButton->OnClicked.AddDynamic(this, &UWidgetClassName::OnClick);
}
void UWidgetClassName::OnClick()
{
//I want to access the index of the clicked button here
}
The code is a bit simplified, I actually create this buttons dynamically inside a loop, so I end up with many buttons, all of which call the same function. Is there a way to "know" which button was pressed, so for example if I press the first button, I get 1, if I press the second, I get 2, etc?
Thanks a lot :)