Cursor for input field with line break

Hi! I’m trying to create input field with cursor, but it not working with line break ( Maybe there is a better strategy?

How it looks
http://185.4.72.186/cursor.gif

	local text_data = gui.get_text_metrics_from_node(input_text)
	local input_scale = gui.get_scale(input_text)
	local cursor_pos = gui.get_position(cursor_node)

	cursor_pos.x = (text_data.width / 2) * input_scale.x
	cursor_pos.y = -((text_data.height - (text_data.max_descent + text_data.max_ascent))/2) * input_scale.y
	if text_data.height == 0 then
		cursor_pos.y = 0
	end
	
	gui.set_position(cursor_node, cursor_pos)
1 Like

I can’t solve this problem :frowning:

I guess you would need to manually calculate line breaks so you know how much text you have on the last line and where to put the cursor. I haven’t attempted this myself though…