How can i set the position of the Textedit?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Baqufff

How can i set the position of the Textedit?

var MousePos = get_global_mouse_position()
var CityName = TextEdit.new()
CityName.position.x = MousePos.x
CityName.position.y = MousePos.y
CityName.set_line(0,str($Camera2D/TextEdit2.get_line(0)))

Invalid get index ‘position’ (on base: ‘TextEdit’)

:bust_in_silhouette: Reply From: kidscancode

Control nodes do not have a position property. If you look at the docs:

or at the Control node’s Inspector, you’ll see that rect_position is the property.

A few other comments:

  1. rect_position is a Vector2 (as is position), so there’s no need to set the components separately.
CityName.rect_position = MousePos

works just fine.

  1. You’ve created a new TextEdit node, but it will not be visible/usable until you add it to the tree with
<some_parent_node>.add_child(CityName)