UCommonButtonBase: Why doesn't any event seem to fire?

I built a class CommonButton that inherits from UCommonButtonBase.

I have several of them in a Scroll Box widget.

I make them selectable and I set a specific “selected style”.

I can see how the selected style applies whenever I click one of my selectable buttons - everything’s great.

However, I tried in various ways to bind functions to events of my common button and none of the events fire.

This is especially weird with this one:

DECLARE_EVENT_OneParam(UCommonButtonBase, FOnIsSelectedChanged, bool);
	FOnIsSelectedChanged& OnIsSelectedChanged() const { return OnIsSelectedChangedEvent; }

… as I can see the selected-mechanism at work, only my events don’t fire.

I tried

Button->OnIsSelectedChanged().AddLambda([this] () { UE_LOG(...) });

and

Button->OnIsSelectedChanged().AddUObject(this, &AMyHUD::Shout);

where

void Shout(bool) { UE_LOG(...) }

Same with OnClicked()

I feel quite comfortable around delegates and events and the related syntax, but this one leaves me puzzled.

Looks like that I can successfully bind delegates within the NativeConstruct of my CommonButton and nowhere else.

Turns out I made a couple of mistakes while troubleshooting my problem.

There doesn’t seem to be a problem with the events.

The only issue that remains: UCommonButtonBase::SetIsSelected(false) only works if Toggable is set.

I now use

using UCommonButtonBase::SetSelectedInternal

and SetSelectedInternal(false, true, false) to unselect my buttons via code and it all works.

1 Like