-
-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make RichTextLabel "Text" property return the whole bbcode text, instead of raw text added from the inspector window #8739
Comments
The See also: |
See the linked issue and discussion 🙂 that's part of the reason behind this |
It's actually really practical when, for example, making a typewriter effect for a textbox and similar. And I assume it's useful for other cases too. |
So... Not being able to capture the node's text information at runtime to send it somewhere else, clone it, or manipulate it, is somehow practical... I'm at loss here. I think it may be me just confusing the real use for this node at this point. So I'm just gonna blame it on myself xD In any case, I figured a way to do what I wanted to do for my prototype. Not really practical, since richtextlabel already holds that information. And saving it twice on another variable seems like a waste. But it works for me heh |
I ran into this myself - and I agree it is "insane" (or at least incredibly unintuitive) that the "get_text" method for a label class doesn't return the text of the label. Really, just think about the API for this class: functions called "add_text" or "append_text" put text in the label...but "get_text" doesn't return the text that was added. Regardless of the intention behind that, the naming of these functions is misleading and unclear. (Don't get me started on the "clear" function not actually clearing the label...jeez.) |
I think there are two major issues here. The first one being the naming on that function not explicitly telling the developer what's going to return. But that's not the main issue here. the REAL problem here is the lack of a function for returning plain text as a string. I find it odd that a node that works around text doesn't even have a string getter property or function. Maybe there is, but then again, there's no documentation about it. (It's been 2 months, almost 3 since I've last posted here and I haven't checked since then, so I may be wrong with that last statment) but in case this goes nowhere and whoever's reading this needs a way to get over this problem, an easy way of doing so is saving the text on an auxiliary variable. It's not pretty at all and not a good practice... but it does the job. |
See #5056. |
A function like this would've been really helpful for me debugging a RichTextLabel that doesn't behave correctly when doing something like |
This comment was marked as off-topic.
This comment was marked as off-topic.
@andrea-calligaris Please don't bump issues without contributing significant new information. Use the 👍 reaction button on the first post instead. |
Describe the project you are working on
Just prototyping
Describe the problem or limitation you are having in your project
So, I'm using a RichTextLabel Node for an online chat I'm prototyping. And I can't sync the content between peers because the "Text" property only syncs raw text written from the inspector window. Anything else I add during run-time with append_text() doesn't get returned. Thus, messages are never in-sync.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
By making the text property return the current bbcode the node is holding at the moment, synchronization would be easier to implement. Besides, people who use this type of node are most likely to use bbcode anyway.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
print( RichTextLabel.text ) <---- Returns the current bbcode either appended and/or written from the inspector window.
RichTextLabel_1.text = RichTextLabel_2.text <------ This should clone the formatted text. Currently it just clones the raw text written from the inspector. If you append_text() and then do that assignment, you will still get the stuff before runtime and not the appended text.
If this enhancement will not be used often, can it be worked around with a few lines of script?
not that I'm aware of? Couldn't find anything on the 4.x docs.
Is there a reason why this should be core and not an add-on in the asset library?
It's a rich text label, clue's on the name. Why does a property that's supposed to return text, doesn't return the text it currently holds. It's insane.
I've seen that in godot 3.x it used to have a property to access the bbcode text. In Godot 4.x it's not mentioned anymore in the documentation. So it's either missing or it was removed. But this should be a core feature for such a node since it's pretty much what it does anyway.
The text was updated successfully, but these errors were encountered: