How to Create a bindable property, like the ones in the UMG (ex: TextBlock)

See UWidget and maybe UImage for references. A boolean example:

Header:

UCLASS(CustomFieldNotify)

/* ... */

	UPROPERTY(BlueprintGetter = "IsSelected", BlueprintSetter = "SetSelected", Category = "PropAlchemy|widget", EditAnywhere, FieldNotify, Getter = "IsSelected", Setter = "SetSelected")
	bool bSelected{ false };

	UPROPERTY()
	FGetBool bSelectedDelegate;

	UE_FIELD_NOTIFICATION_DECLARE_CLASS_DESCRIPTOR_BEGIN(PROPALCHEMYWIDGET_API)
		UE_FIELD_NOTIFICATION_DECLARE_FIELD(bSelected)
		UE_FIELD_NOTIFICATION_DECLARE_ENUM_FIELD_BEGIN(bSelected)
		UE_FIELD_NOTIFICATION_DECLARE_ENUM_FIELD_END()
		UE_FIELD_NOTIFICATION_DECLARE_CLASS_DESCRIPTOR_END();

CPP:

UE_FIELD_NOTIFICATION_IMPLEMENT_CLASS_DESCRIPTOR_OneField(UPropAlchemyWidgetButton, bSelected);


void UPropAlchemyWidgetButton::SetSelected(const bool& bInSelected) noexcept
{
	bSelected = bInSelected;
	BroadcastFieldValueChanged(FFieldNotificationClassDescriptor::bSelected);
	LoadBrushColor();
}
1 Like