Godot: add_child and call_deferred("add_child", node) dont add RichTextLabel.

Created on 5 Apr 2020  路  4Comments  路  Source: godotengine/godot

Godot version:
3.2.1
OS/device including version:
Mac OS 10.13.6
Issue description:
Can't add node.
Steps to reproduce:

extends Control
var richTextLabel = RichTextLabel.new()
var rtl = RichTextLabel.new()
func _ready():
    richTextLabel.set_name("rich")
    richTextLabel.set_use_bbcode(true) 
    richTextLabel.set_bbcode("BBCode [color=blue]blue[/color]")
    richTextLabel.set_position(Vector2(0,0))
    richTextLabel.set_visible_characters(-1)

    rtl.add_text("Hello")
    rtl.set_visible_characters(-1)
    addNodes(rtl, richTextLabel)

func addNodes(rtl: RichTextLabel, richTextLabel: RichTextLabel):
    self.add_child(rtl)
    self.call_deferred("add_child", richTextLabel)
archived

All 4 comments

I can't reproduce the issue.

I've copied the code but the nodes are clearly added as children:
image

I think the problem is, that they aren't visible. That's probably because the size is (0, 0). I've manually edited the rect_size:
image image

Thanks for responding @TheFlamyy
Since, visible characters is set to -1 shouldn't the contents be displayed. Is there a way to set the rect_size by code in gdscript?

Since, visible characters is set to -1 shouldn't the contents be displayed. Is there a way to set the rect_size by code in gdscript?

Sure is:

rtl.rect_size = Vector2(100, 200)

@Ev1lbl0w Thanks a lot. That worked.

Was this page helpful?
0 / 5 - 0 ratings