Changing text node value does not change its pick node size? (SOLVED)


Testing with a clean project, clean gui, Windows 10, editor 1.2.142

function on_input(self, action_id, action)
	if action.pressed and gui.pick_node (txtNode, action.x, action.y) then
		if gui.get_text (txtNode) == "A" then
			gui.set_text (txtNode, "LONGER WORD")
			gui.set_text (txtNode, "A")

function init(self)
	txtNode = gui.new_text_node (vmath.vector3 (100, 100, 0), "A")
	gui.set_pivot (txtNode, gui.PIVOT_NW)
	gui.set_size_mode (txtNode, gui.SIZE_MODE_AUTO) (".", "acquire_input_focus")

If you click on text node “A” so it changes to “LONGER WORD”, I was expecting pick node to resize so you can now click on the entire width of “LONGER WORD”. Instead you can only click on the letter “L” or likely just the width of the original text “A”.

I tried setting size_mode of the text to auto, but same results. Tried with default font, and importing a different font.

What is the proper way to do this? Currently my workaround is that whenever I change values of text nodes, I compute the metrics of the text and do a set_size again, but isn’t there a simpler way?



Calculating size based on text metrics is the way to solve this. Automatic resizing could perhaps be implemented for single line text.


Ok got it, that’s how I am doing things now, just want to make sure I didn’t miss anything. Thanks!