Upcoming New Property on Text Object - ContentText

Dear developers,

Next week, we are planning to add a new property called ContentText to Text Objects. (The property is a ReadOnly string that shows you what is being rendered by the current text object without extra formatting tags.) In order for all of your places to function correctly, please make sure you are not accessing children with name ContentText under text objects directly through .ContentText.

For the sake of both code functionality and API safety, we always suggest getting reference of an exiting child using the following code:

Parent:WaitForChild("ChildName") / Parent:FindFirstChild("ChildName") 


This new property is the rename of this reverted change:

If you need to make changes to your code because of this, please let us know in the thread. Thank you!

133 Likes

The thousands of lines of code I’ve written over the years could easily cause this to break. I doubt I probably used ContentText anywhere, but if any of my old games break now we know why.

Using FindFirstChild to work around new property names is definitely clunky and we need some way of making Roblox realise we want to access a child, not a property. I just dont know how feasible this is.

Many frameworks such as Fusion implement this using a Children descriptor symbol (since Children itself is a deprecated copy of GetChildren) to access children. (Though I dont want to be typing Part.Children.Part2.Children…)

28 Likes

The solution in the engine space is generally to offer some kind of path selector DSL, which can double as a way to let you quickly find and iterate sets of children of particular type / with particular tags and attributes in addition to accessing single children. It’s an idea that’s been thrown around occasionally.

26 Likes

A use case for anybody curious:

Currently, if you try to make a Typewriter (the thing that goes through the text and looks like it’s ‘typing’ out the words) that supports rich text, you’ll run into an issue; If you want to stop the typewriter once it’s reached the end of a string’s worded content, you’ll have to know how long the string is. And unless you create some hacky way to omit RichText tags, you won’t know how long the actual ‘content’ of the string is.

That’s where this property comes in

23 Likes

I still think “RenderedText” would be a less intrusive, yet more clear, name. ContentText alone doesn’t really say much for someone without much context behind the property.

65 Likes

There’s a new property called ContentText applying to text based GUI objects. There’s a chance some GUIs have a child element named this and by default, Instance properties are looked for before looking at their children’s names when indexed. For example, if you name an Instance called Parent underneath a script, trying to access it would return what the script is parented to, NOT the Instance named Parent due to it already being a property of the script.

4 Likes

I’m a bit outdated, but what is ContentText for? There’s no information in the original post.

3 Likes

Read the announcement properly :pray:

4 Likes

It shows what the text actually reads when using rich text.

2 Likes

Why did you opt to make this a property rather than a getter method? Surely the latter would make more sense?

textLabel:GetTextContent()
textLabel:GetRenderedText()

etc.

That way, you don’t run into the same name collision issue.

36 Likes

While your proposed solution would probably eliminate any issues, as it is not likely anyone has an instance named GetTextContent; you’d be removing the ability to listen to ContextText changes using :GetPropertyChangedSignal.

This will be invaluable to bind effects to text, and its not something I want to miss out on.

17 Likes

Does this involve using any of the Grapheme properties still?

I’m really curious about this use and would like to learn more due to using a Typewriter visual.

2 Likes

I don’t understand… can’t you just check the length of the source string?

2 Likes

It’s not that simple due to rich text. The Text property of text GUIs will include characters that aren’t actually part of the text displayed to the user and only serves the purpose of formatting the text the user sees.

4 Likes

Perfect. Thank you Roblox. I had Content in text labels in older games, and ContextText sounds like an actual property.

2 Likes

most things are good as long as there is a switch to turn it off, at least in my opinion. what i mean is
can there be a switch to turn it off

3 Likes

It’s a single property that only gets updated (presumably) whenever you change .Text, adding some option to disable this property would likely be more wasteful than just leaving this property always on.

6 Likes

This seems pretty useful considering I use typewriter effects a lot.

2 Likes

This is going to really speed up developing times, thank you very much roblox.

2 Likes