I want to do a widget to be used as a component in other widgets.
And the text color cannot be changed.
And the background color doesn’t work until the “inherit” option is Checked and Unchecked.
This is my code:
//-------------------------------------------------
// DEFINITION
//-------------------------------------------------
UCLASS(Abstract, BlueprintType, Blueprintable)
class UEditableTextBlockExt : public UUserWidget
{
GENERATED_BODY()
private:
UPROPERTY(meta = (BindWidget) )
UEditableTextBox *TextBox = nullptr;
UPROPERTY(EditAnywhere)
FString TheText = FString("Parent");
UPROPERTY(EditAnywhere)
bool UseWidgetStyle = false;
UPROPERTY(EditAnywhere)
FEditableTextBoxStyle WidgetStyle = FAppStyle::GetWidgetStyle<FEditableTextBoxStyle>("NormalEditableTextBox");
virtual void NativePreConstruct() override;
}
//-------------------------------------------------
// IMPLEMENTATION
//-------------------------------------------------
void UEditableTextBlockExt::NativePreConstruct()
{
Super::NativeConstruct();
TextBox->SetText( FText::FromString(TheText) );
if (!UseWidgetStyle) return;
TextBox->WidgetStyle = WidgetStyle;
}
This is a sample video:
What’s wrong?
Thank you so much!!