Send bool from widget to character

I gave up for I while because I couldn’t solve it. I’m back again to see if I can find a solution this time (6h coding today and nothing, kinda sad).
I have both tried to follow your instruction as close as possible, as well as other tutorials. I moved the binding into the constructor of MyCharacter. I can’t find any information about the macro “BIND_OBJECT_DELEGATE”? it has error “identifier is unidentified” and everything after is marked in red.

	TSharedPtr<SConstructionWidget> MyConstructionWidget;
	MyConstructionWidget = SNew(SConstructionWidget).OnBuildingClickedDelegate(BIND_UOBJECT_DELEGATE(FBuildingClickedSignature, SlateOnBuildingClickedCallback));

I have also tried BindUObject. But nothing happens when the button is pressed (it’s not bound)

	TSharedPtr<SConstructionWidget> MyConstructionWidget = SNew(SConstructionWidget);
	MyConstructionWidget->OnBuildingClickedDelegate.BindUObject(this, &AMyCharacter::HandleOnBuildingClicked);

lastly I tried CreateUObject. Since what you described earlier is that SCompoundWidget is not an UObject. It didn’t work.

	TSharedPtr<SConstructionWidget> MyConstructionWidget = SNew(SConstructionWidget);
	MyConstructionWidget->SetOnBuildingClickedDelegate(FOnBuildingClickedSignature::CreateUObject(this, &AMyCharacter::HandleOnBuildingClicked));

Within MyConstructionWidget I have code as follow. I Don’t know what you mean by callback function, I tried two different ways. But neither worked:

DECLARE_DELEGATE_OneParam(FOnBuildingClickedSignature, bool /*EnteredConstructionMode*/);

class MY_API SConstructionWidget : public SCompoundWidget
{
public:

	SLATE_BEGIN_ARGS(SConstructionWidget)
		: _OnBuildingClickedDelegate()
	{}
	SLATE_ARGUMENT(TWeakObjectPtr<class AMenuHUD>, OwningHUD)
	SLATE_EVENT(FOnBuildingClickedSignature, OnBuildingClickedDelegate)
	SLATE_END_ARGS()

	void Construct(const FArguments& InArgs);

	FReply OnBuildingClicked() const;
	FReply OnReturnClicked() const;

	void SlateOnBuildingClickedCallback(bool EnteredConstructionMode);

	//void SetOnBuildingClickedDelegate(FOnBuildingClickedSignature Callback) {
	//	OnBuildingClickedDelegate = Callback;
	//}
	
	FOnBuildingClickedSignature OnBuildingClickedDelegate;

	TWeakObjectPtr<class AMenuHUD> OwningHUD;

	virtual bool SupportsKeyboardFocus() const override { return true; };
};

In the cpp file I have combined previous function into one. When pressing my building button I only get the log “Building button is pressed”. So the binding doesn’t work.

FReply SConstructionWidget::OnBuildingClicked() const
{
	if (OwningHUD.IsValid()) {
		UE_LOG(LogTemp, Warning, TEXT("Building button is pressed"));
		if (OnBuildingClickedDelegate.IsBound()) {
			UE_LOG(LogTemp, Warning, TEXT("Is Bound"));
			OnBuildingClickedDelegate.Execute(true);
			OwningHUD->RemoveAllMenus();
		}
	}
	return FReply::Handled();
}