Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | nationality |
I’m trying to make a vboxcontainer inside a scrollboxcontainer for the purpose of holding a long string of rich text labels.
It works for the most part, but often a label won’t appear, seemingly at random. When the screen is refreshed, it reappears.
I think it’s because get_content_height is sometimes returning 0. I have no idea why it would do that, because it’s usually getting it right.
Here is the relevant code.
func determine_min_size_for_box(box : Control) -> Vector2:
if box is RichTextLabel:
var y = box.get_content_height()
return Vector2(0, y)
return Vector2(0,0)
var totalOutputBoxes = 0
func print_output(client, newParagraph:= false, endLine:= false):
for newOutput in client.toSay:
Global.debug.message("\nNewOutput: " + String(newOutput) + ". ")
if newOutput is String:
Global.debug.message("Creating new text box. ")
totalOutputBoxes += 1
var textBox = RichTextLabel.new()
#textBox.name = "OutputBox" + String(totalOutputBoxes)
textBox.bbcode_enabled = true
textBox.scroll_active = false
textBox.selection_enabled = true
textBox.grow_horizontal = true
textBox.rect_min_size = determine_min_size_for_box(textBox)
textBox.append_bbcode(newOutput)
output.add_child(textBox)
#set_min_size_on_box(textBox)
var allOutput = output.get_children()
for outputBox in allOutput:
outputBox.rect_min_size = determine_min_size_for_box(outputBox)
client.toSay = []
client.currentOutputBox = 0