Announcement

Collapse
No announcement yet.

Make a bind on a User Created Widget?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Make a bind on a User Created Widget?

    Hi I was wondering if there is a possibility to make a bind on a child widget for the parent. I have several widgets where I have a special text box, and I want to set Localization for it but I have to do Set Text for each text area. It would be nie If I could make a bind where I can set it to a c++ FText instead of setting them separately. Does anyone know a way to create a bind from child widget?

    #2
    Oh well I managed to get it working by making my own widget class. Hopefully this could be done in blueprint in the future so that you could implement it from there.
    Here is the base code.

    UCLASS()
    class UBindTitle : public UUserWidget
    {
    GENERATED_BODY()

    public:
    // Binding
    UPROPERTY()
    FGetText TitleTextDelegate;

    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "LocalizeTitle")
    FText TitleText;

    virtual void SynchronizeProperties() override;
    protected:
    // UWidget interface
    virtual void OnBindingChanged(const FName& Property) override;
    };


    void UBindTitle::SynchronizeProperties()
    {
    Super::SynchronizeProperties();

    TAttribute<FText> TextBinding = OPTIONAL_BINDING(FText, TitleText);
    TitleText = TextBinding.Get();
    }

    void UBindTitle::OnBindingChanged(const FName& Property)
    {
    Super::OnBindingChanged(Property);

    static const FName TextProperty(TEXT("TitleTextDelegate"));

    if ( Property == TextProperty )
    {
    TAttribute<FText> TextBinding = OPTIONAL_BINDING(FText, TitleText);
    TitleText = TextBinding.Get();
    }
    }

    Comment

    Working...
    X