Upcoming New Property on Text Object - ContentText

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.

18 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

You could use :GetPropertyChangedSignal on the Text property which should be pretty much the same (unless you add an empty tag for some reason).
Nonetheless I still prefer having it as a property

3 Likes

RenderedText was (unsurprisingly) considered as one of the options.

The reason that we didn’t go with that one is that it has a strong implication that the property only works when the text is actually being rendered to the screen. Which is not the case, you can read the ContentText property and use its value even for an Instance that isn’t parented to the hierarchy.

7 Likes

Perhaps then a better solution would be to introduce extra specificity? ContentText as-is is still relatively vague. What about a name such as RichTextContent?

3 Likes

Including RichText specifically in the naming is also undesirable in some ways, because while RichText is currently the only way for the Text property and the actual processed text to mismatch, there may be other ways for that to happen at some point in the future, and it would be nice for this property to also interact well with those.

Though obviously including a reference to RichText in the naming would make it more clear for the time being, so it’s a tradeoff.

3 Likes

If I’m not wrong, this read-only value is a string? If so, why not call it “TextContents” or “ContentsOfText” or something that is a bit more specific. I can see how coming up with a name for this was difficult, because It took me a good while trying to think of a good name for it.

In general my thoughts were:

  • TextVolume
  • TextDetails
  • TextCapacity
  • TextSum (More for something like numbers so I didn’t quite know how I felt about this one)

Anyways that’s all the name ideas I had. Hopefully that helps generate a new name for it, because I feel like “ContentText” is just something that is way to generic and that’s definitely a name that tons of people (myself included) probably used at some point.

Maybe make some sort of engine warning to the user who attempts to use a Child that is named “ContentText” directly through the . navigation instead of :WaitForChild() and :FindFirstChild()?

Anyways good update. (I think?)

3 Likes

What do you mean by this? It’s just the text?

2 Likes

What they mean is, if someone uses something like RichText to achieve like line breaks and stuff like n/,

it would be like Hello world (2 spaces inbetween Hello World

while not using RichText, it would only have 1 space. It’s to show the accurate string over the normal Text property. I feel it’s a bit redundant as well, but I think this is what they mean.

3 Likes

If the RichText is on, It would return you the string with all the rich text tags removed. When the RichText is off it will be equivalent to Text.

4 Likes

What about something like RawContentText, CurrentDisplayedText, or CurrentContentText? Something more specific that would be less likely to cause things to break.

2 Likes