Hello thats how to hopefully reproduce the behaviour

  • Create a scene with any type of Node as root.
  • Add a control as child.
  • increase its Rect as you like.
  • attach a script (an integrated one is enough) and add this function

func _draw(): draw_rect(get_rect(), Color.crimson, false, 4.0)

  • duplicate the Control
  • Move the duplicate elsewhere.

Look at the difference between what is drawn and what are the Rect positions.
Optionnally you can print the Control rects, its position is still like the properties

It has consequences in my game because I use control just because it give access to a rect editor in the editor.
But with more than one Control this behaviour appears.
Do you know an alternative for drawing rects in the editor ?

Ok I will use a Control during the setting of Rects, then I copy the values into the script then I will remove the Control. Its less automatic but I can continue my project.

I was trying to reproduce the issue. What I have seen is that CanvasItem.draw_rect() uses the actual position of the Control as the origin of coordinates. So if you want to draw the outline of a Control you should use something like:

draw_rect(Rect2(Vector2.ZERO, get_rect().size), Color.CRIMSON, false, 4.0)

I think this should be clarified in the documentation.

Note: I am using Godot 4.1.1

In your _draw() function, the rectangle you are drawing is positioned relative to the Control itself, not the top-level scene node.

If you want to draw rectangle around the perimeter of the control you want to do this:

func _draw():
	var my_rect = Rect2(Vector2(0,0), get_rect().size)
	draw_rect(my_rect, Color.CRIMSON, false, 4.0)

This draws a rect that is the same size as the Control, positioned at (0,0), which is the origin of the control.

Oh... these nested coordinates are not compatible with my stupidity.
Thank you.