Need Help: Problem with my Rich Text Image Decorator CPP. Subclass

I tried to create my own Rich Text Image Decorator Subclass in cpp. that uses custom format, instead of the default one: <img id>.

I tried my best, but nothing I did fixed the issue I’m strugging with. Any fix on that?


What is FRichTextBlockDecorator ?

You are supposed to create your own struct there, either inheriting FRichTextDecorator, or directly from the base interface ITextDecorator.

class FMyDecorator : public FRichTextDecorator
{
    virtual bool Supports(const FTextRunParseResults& RunParseResult, const FString& Text) const override
    {
        return (RunParseResult.Name == TEXT("IMG"));
    }

    // Override the desired Create function...
};

TSharedPtr<ITextDecorator> UMyRichTextDecorator::CreateDecorator(URichTextBlock* InOwner)
{
    return MakeShareable(new FMyDecorator(InOwner));
}

Bump. I got lost and I think I’m sidetracked.

To make it clear, instead of using the default format of base Rich Text Block Image Decorator.

<img id="Attack1"/>


I’m trying to make it use my own format.

<tid id="Attack1"/>


And I tried to do this by overriding this in base class of RichTextBlockImageDecorator:

Not even this set up helped me change the format.


Bump, still trying to make it work:


Hmm the problem with your first approach is that the classes used by URichTextBlockImageDecorator are not exposed by the engine, so you cannot access them.

If you really want something similar, you pretty much have to copy the entire RichTextBlockImageDecorator.cpp file and then adjust the code.

Regarding the second error message, I forgot to include a constructor, the default constructor only accepts InOwner.

class FMyDecorator : public FRichTextDecorator
{
public:
    FMyDecorator(URichTextBlock* InOwner, URichTextBlockImageDecorator* InDecorator)
        : FRichTextDecorator(InOwner)
        , Decorator(InDecorator)
    {}