Hi so I’ve been trying to make a custom rich text decorator. The idea behind it is if you mouse over a specific word a tool tip will pop up, the way I’m currently trying to achieve this is by adding a text box to the rich text box instead of a image but I’ve hit a bit of a snag and am not sure how to continue.
I have also been looking at richImages source code but I’m not sure how much is applicable, can any body offer some advice on how to get it working or a better way to achieve it.
Note: I also posted this posted this How to use slates SetToolTip with UMG widget which ties into this
.h
UCLASS()
class UMG_API URichTextTooltip : public URichTextBlockDecorator {
GENERATED_BODY()
public:
virtual TSharedPtr<ITextDecorator> CreateDecorator(URichTextBlock* InOwner);
URichTextTooltip(const FObjectInitializer& ObjectInitializer);
};
.cpp
class UMG_API FRichTextTooltipS : public FRichTextDecorator {
public:
FRichTextTooltipS(URichTextBlock* InOwner, URichTextTooltip* decorator) : FRichTextDecorator(InOwner) {
};
virtual bool Supports(const FTextRunParseResults& RunParseResult, const FString& Text) const override {
if (RunParseResult.Name == TEXT("Wid") && RunParseResult.MetaData.Contains(TEXT("id"))) {
const FTextRange& IdRange = RunParseResult.MetaData[TEXT("id")];
const FString TagId = Text.Mid(IdRange.BeginIndex, IdRange.EndIndex - IdRange.BeginIndex);
}
};
protected:
virtual TSharedPtr<SWidget> CreateDecoratorWidget(const FTextRunInfo& RunInfo, const FTextBlockStyle& TextStyle) const override {
const bool bWarnIfMissing = true;
RunInfo;
TSharedPtr<STextBlock> Box = SNew(STextBlock);
//Box->SetToolTip();
return Box;
};
// = SNew(STextBlock)
};
TSharedPtr<ITextDecorator> URichTextTooltip::CreateDecorator(URichTextBlock* InOwner)
{
return MakeShareable(new FRichTextTooltipS(InOwner, this));
}
URichTextTooltip::URichTextTooltip(const FObjectInitializer& ObjectInitializer) : URichTextBlockDecorator(ObjectInitializer) {
}