-
-
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
RichText: get_visible_line_count() returns wrong value #18722
Comments
In my case get_visible_line_count() is always 0 for the RichText label |
Doesn't work for label for me. I always get a 0 on the label. |
What happens to me is that get_visible_line_count only works if I dont set linebreaks as \n and let the richtextlabel do it and get_visible_line only works if I put break lines with \n. This makes scroll_to_line to fail if I use the former case :S Godot 3.1 Beta2. Windows 10. I guess this was never solved since it is still opened. Regards |
Did you tried waiting one idle frame before calling it? A few days ago I had a similar issue and fixed it by waiting one idle frame: # RichTextLabel
func update_size():
yield(get_tree(), "idle_frame") # wait one frame
rect_min_size.y = get_content_height() |
Yeah, no change. It returns always 1. Not sure if I am misunderstanding something about righttextlabel. |
I just tried in Godot 3.1.1, it always return 0 even if I have 5 lines in it. Also, I did these tests in |
I think it would be useful if there was an intermediate object to generate text, similar to Unity's |
I can look into this at some point -- There's probably an issue with the logic of the original implementation. This would also help extend rich text effects for more features (such as line context awareness!) |
please fix this, I can"t automatically scroll at runtime once there are more visible lines then space to fit. Scroll_to_line always throws an out of bounds error due to incorrect lines.size |
visible_line_count issue: So after doing some work, I've found out that we're getting wrong values because line_count issue: The line_count doesn't count newlines( |
After talking to other Devs, it turns out |
okay I get your point about the multi-line spanning across multiple lines. It is counted as one. My workaround to enable auto scroll: Add the text to the Textlabel each time a new character is turning from invisible to visible, thus avoiding the use of visibility at all. |
@Railwanderer |
So, I've made some small changes and now it returns the correct number of visible lines for now. Again, it returns the correct values only after being drawn. I'll make a PR soon. |
Godot version: 3.02
OS/device including version: Win 10
Issue description:
get_visible_line_count and get_line_count with RichText works not as expected (not like Label).
get_visible_line_count does not return the visible lines, it seems more like the line count. And get_line_count seems to return always 1.
I try to make a SpeakBubble which grows automatically to fit the text. I solved that by growing the Label/RichText while get_visible_line_count < get_line_count. That works with the Label, but not with RichText.
The text was updated successfully, but these errors were encountered: