-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Some RichTextLabel getter methods only return a correct value on the next frame #36381
Comments
Duplicate of #12884. That said, we should update the documentation to mention the character count functions won't work in a ready callback unless they're called using |
then we'll have the same issue with I can make a PR, should I add a note to both? |
I wanted to report the same problem, but found this issue. extends Node
func _ready():
var rtl = $RichTextLabel
rtl.bbcode_text = "[color=red]hello[/color]\n"
print("content_height: ", rtl.get_content_height())
print("line_count: ", rtl.get_line_count())
print("total_character_count: ", rtl.get_total_character_count())
yield(get_tree(), "idle_frame")
print("---")
print("content_height: ", rtl.get_content_height())
print("line_count: ", rtl.get_line_count())
print("total_character_count: ", rtl.get_total_character_count())
# content_height: 796355904 <-- An uninitialized variable?
# line_count: 2
# total_character_count: 0
# ---
# content_height: 30
# line_count: 2
# total_character_count: 5 I think this should be considered a bug. Information should be updated immediately, in the |
@dalexeev I'm not sure if it's even possible to make those methods synchronous in the first place. Otherwise, they probably would be synchronous already 🙂 |
@Calinou I meant a user-defined function ( func write(text):
rtl.bbcode_text += text
yield(get_tree(), "idle_frame") # hack!
tmr.start()
while rtl.visible_characters < rtl.get_total_character_count():
yield(tmr, "timeout")
rtl.visible_characters += 1
tmr.stop() (My function is already asynchronous because the loop contains |
Hi, |
Hi I have similar problem with GetContentHeight() |
I encountered a problem when setting the text via gdscript. For any message set the line_count will always return 1, no matter how many lines are shown/drawn. visible_line_count returns the correct values, increasing while revealing them via a timeout signal. I wanted to set scroll_to_line to scroll down while revealing the lines, but always hit an index out of bounds error due to the incorrect lines.size() value. Found a workaround using a deferred call to the scroll bar. Still probably should be fixed though as invisible_line count works |
Godot version: 3.2.stable
OS/device including version: Win 64
Issue description:
get_total_character_count() returns 0 in a RichTextLabel with text.
Steps to reproduce:
This should work according to the docs:
https://docs.godotengine.org/en/3.2/classes/class_richtextlabel.html#class-richtextlabel-method-get-total-character-count
possibly related: #874
The text was updated successfully, but these errors were encountered: