Trying to fit a certain text node to a variable sized area. The text has linebreak.
Still when using gui.set_size the node doesn’t change it’s linebreak but breaks at the width it was created.
I also tried creating a new node with code but same results. When creating a new textnode there are no way to set size at creation so it cannot be solved at creationtime.
Hmm, I would have expected it to adapt the linebreaks to the current width of the node. This must be an oversight or a simplification done when the text node was implemented. Any thoughts on this @Mathias_Westerdahl (I’m asking you since you did a bit of work on the text nodes and labels not too long ago)?
Well, perhaps I’m not following you correctly, but the code supports it. Does this test illustrate what you wish to do? https://forum.defold.com:/uploads/default/original/2X/1/131e8083115d5a75f7477465f3c886e97305b142.mov
The setup is one text object, with line_break set to true, and the code is simply (text.gui_script):
function init(self)
gui.animate(gui.get_node("text"), "color", vmath.vector4(1,0,1,1), gui.EASING_LINEAR, 2, 0, nil, gui.PLAYBACK_LOOP_PINGPONG)
gui.animate(gui.get_node("text"), "size", vmath.vector4(50,100,0,1), gui.EASING_LINEAR, 2, 0, nil, gui.PLAYBACK_LOOP_PINGPONG)
end
Ah, I realised that it was all about the text node size mode being set to AUTO.
Problem is that this checkbox isn’t visible in a text node (only for box nodes for some weird reason editor 1.2.95).
Changing it with code (or in a text editor in the gui file) made all the difference.