0 votes

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

Invalid get index 'position' (on base: 'TextEdit')

in Engine by (12 points)

1 Answer

0 votes

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.

2) You've created a new TextEdit node, but it will not be visible/usable until you add it to the tree with

by (21,714 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.