Clone tree label not showing

[new to Defold; experienced programmer]

I am cloning a simple node tree that is a box with a label. Literally a colored box with a text subnode. The boxes are showing up, not the labels. The label is changing, as shown in my print statement, but not visible. Here is my code:

local cnode_tree = gui.clone_tree(gui.get_node(‘topicBtn’))
local cnode = cnode_tree[hash(‘topicBtn’)]
local tnode = cnode_tree[hash(‘topicT’)]
print('setting topic: '…top)
print('old label: '…tostring(gui.get_text(tnode)))
gui.set_text(tnode, top)
print('new label: '…tostring(gui.get_text(tnode)))
gui.set_position(cnode,vmath.vector3(512,500-idx*82,0))
gui.set_layer(cnode, ‘results’)
gui.move_above(tnode, cnode)
gui.set_enabled(tnode, true)
gui.set_visible(tnode, true)

I am sure the last 3 are irrelevant, but just trying. The set_text and get_text are working, the label has the new text.

What am I forgetting?

This works, but then the label is not attached to the box node.

local cnode_tree = gui.clone_tree(gui.get_node(‘topicBtn’))
local cnode = cnode_tree[hash(‘topicBtn’)]
– local tnode = cnode_tree[hash(‘topicT’)]
local tnode = gui.clone(gui.get_node(‘topicT’))
print(setting topic: …top)
print(old label: …tostring(gui.get_text(tnode)))
gui.set_text(tnode, top)
print(new label: …tostring(gui.get_text(tnode)))
gui.set_position(cnode,vmath.vector3(512,768-idx*82,0))
gui.set_position(tnode,vmath.vector3(512,768-idx*82,0))
gui.set_layer(cnode, ‘results’)
gui.set_layer(tnode, ‘results’)
gui.move_above(tnode, cnode)

It’s not apparent to me right away, so if someone else has an idea do jump in!

Does the initial node tree look fine in the editor? Is the text node (tnode / topicT) a child of what I presume to be the box node (cnode / topicBtn)? Can you show the setup in the editor?

All of that was true as far as I know, I checked it several times. Not useful to show it now, as it has all been working fine since it started working. I have added dozens of nodes and all working fine. I assume this should be closed, I don’t know what I did differently.

1 Like