How to access data from Rich Text Style Row Structure

How can you get the data from a Rich Text Style Row Structure? It doesn’t have a break node.

I have a Data Table of that type, and I want to get a row from that table with Get Data Table Row, which returns a wildcard but you can set that as a Rich Text Style Row, but the problem is like I said, you don’t have a break node to get for example the color, or the font. Right now I need to get the color.

You can try using the base text box style and then injecting it into the rich text box style override

In the base struct you have access to the sub elements. Not a perfect solution but it’s at least exposed to blueprints.

Here is a bit better explained on how I want to use it, and how I want to get the data:

When the Data Table is used for rich text then that is easy as the format is used when you set the text.

Yes, you can simply use the same values for those other elements, but in the future if you change for example the color, you want something else, beside changing it only inside the Data Table and be reflected everywhere, you also have to change every widget that used data style similar to that from DT.

Don’t use RichTextStyle row then. Just use Text Style Block to save the information in your DT.

RichTextStyle internally uses Text Style Block just nested. Use Text Style Block to sync your ui.

Or even better just use Slate Widget Styles to homogenize your UI.

Example for a button:

For a textblock

That’s what they are there for in the engine.

There is no such row structure available when creating a new Data Table.

Also this is not available.

Can it be that you are thinking of a different way of doing what I want?

What I was talking is when you create a new Data Table you are prompted to “Pick Row Structure”, then from the list you pick “Rich Text Style Row”, and then use that Data Table for the Rich Text Block / Text Style Set and later with the tag for each style when setting the text.

And now that I have some styles in that Data Table, I want to get the data from it and use it for other elements that have “Font” / “Text Color” / …, to keep it the same everywhere, and only have to change the style inside the Data Table to apply for all elements that are based on that.

The styles are static, they are only changed inside the editor by manually changing the style inside the Data Table, for example if I want to change the text color from red to blue. They are not changed by the user and can’t be changed/don’t need to be changeable once the game is packed.

Do a workaround by making your own struct

#pragma once

#include "CoreMinimal.h"
#include "UObject/NoExportTypes.h"
#include "Styling/SlateTypes.h"
#include "CustomStyle.generated.h"

/**
 * 
 */
USTRUCT(Blueprintable,BlueprintType)
struct YOUR_API FCustomStyle : public FTableRowBase
{

	GENERATED_USTRUCT_BODY()

	UPROPERTY(EditAnywhere, Category = Appearance, BlueprintReadWrite)
	FTextBlockStyle TextStyle;
};

Then you can make a custom datatable based on it and access all of the data

Or in BP

Then make your data table with it

As you can see you can basically copy the internals of the rich text style and use it as your own with access to all parts of the style.

While with this you can access it’s data, you can no longer use that Data Table as “Text Style Set” for a Rich Text Block. So it still can’t be used as an “Universal Style Data Table”.

In terms of your example, “MyStyleDT” can not be used as “Text Style Set” for a Rich Text Block inside the “NewWidgetBlueprint”.

This exactly sets the style for the rich text block via the custom struct.

Data table entry

In game ui with override

image

Second entry

Setting the yellow row from dt


in game

image

Specific color if needed

image

Yes and no, as there is a catch with this.

Yes, it does work to set the color for a Rich Text Block based on one row.

No, well because of the last part from “Yes”, as it removed the beauty of having a Rich Text Block in the first place, meaning you can combine as many styles as you want for a single block of text.

I hope my answers didn’t came up as rude or anything else, I am grateful for your time in trying to help me!

Ah ok so you want to dynamically load in the sub structs of the rich text style row and access their colors etc.

I was under the impression that you just wanted to store the colors / style in a dt for style switching of your ui.

This might need a c++ work around as some parts are not exposed to blueprints.

Yeah at this point either I have to do something in C++ or even changing parts of the source code to be visible/accessible in blueprints.

What I wanted to do is this:

  1. I want to have a Data Table that contains a list of text styles (with fonts, color, shadow, highlight and everything else the text style has), kinda like a “universal list of text styles” in a single file
  2. I want to be able to use this Data Table to set it as “Text Style Set” for any Rich Text Block from any widget I might use a Rich Text Block in
    2.a) In order to use a Data Table as “Text Style Set” for Rich Text Block, it is required to have the row structure as Rich Text Style Row when it is created
    2.b) If Rich Text Style Row is used, then when you get a row from the Data Table it doesn’t have a break node so that you can only get the font and the color for example.
    2.c) I could even make some rows to be used as background for a Text box, and simply ignore everything else beside the value for Text Style / Color, as I would only need a color for background
  3. When I don’t have a Rich Text Block, I want to use the same Data Table and get the font and color to use it for a simple Text as an example by getting the row based on some logic (similar how you decide which tag from DT to use for a given part of the text inside the rich text)
  4. This way, if I want to make a text style color from 0,255,0 to 0,150,0, while still working in editor before packing the game, I only have to edit a single DT and it will “apply” the new color across all widgets

I really like working with templates whenever I can. They can be annoying to create, but once you have them, they are making your like a lot easier in time, when you have to create the same thing multiple times.

Tried inheriting from FRichTextStyleRow and added a function to extract the style

inline FTextBlockStyle GetTextStyle() { return TextStyle; };

Then called a static library to extract it from the struct

FTextBlockStyle UMyBlueprintFunctionLibrary::GetStyle(FRichTextStyleRowExtra row)
{
	return row.GetTextStyle();
}

but the rich text doesn’t seem to want to take in a datatable struct even if it’s directly inherited from FRichTextStyleRow

It’s a shame because the info is accessible via the static lib.

EDIT:
ok found a workaround to access the richtext data :slight_smile:

Just make a static library

.h

	UFUNCTION(BlueprintCallable)
	static FTextBlockStyle  Simplify(FRichTextStyleRow row);
FTextBlockStyle UMyBlueprintFunctionLibrary::Simplify(FRichTextStyleRow row)
{
	return row.TextStyle;	
}

Full code for lib
MyBlueprintFunctionLibrary.h (470 Bytes)

MyBlueprintFunctionLibrary.cpp (286 Bytes)

Just replace YOUR_API with your project api

requires to add “UMG” module in build file
example:

PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "EnhancedInput" , "Slate", "SlateCore" , "UMG" });

You can now extract the data!

RTSR datatable is of type RichTextStyleRow

Better to not modify engine source if it can be done another way.

1 Like

You really didn’t wanted this to “defeat” you. :smile:

I’ll do that. Thank you!

I only have one change to the engine, to reverse a decision made by UE, it is a really small thing, but something that I really need. I might add a pull on GitHub to how I changed it to work now with newer version.

Guess I’m just stubborn :stuck_out_tongue:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.