- it seems that I cannot change the size of a Control child of a container node
You can but it is inadvisable for two reasons: 1) Control nodes are meant for GUIs so they're meant to stay uniform across any size/resolution display. 2) If you resize the child's rect_size
in such a way that it increases the rect_size
of the parent, the resizing of the child will be overridden by the values calculated for it when the parent is resized (which should always fire last).
- This only occurs the first time that the confirmation container node is made visible, and not when it is subsequently made visible again
From my tinkering with your code that is not the case. This particular behavior is consistent and has to do with how you are calling the function. (explained below)
- This does not occur for the file select container node even though it is initially not visible and is later made visible
The main difference here is you are using call_deferred("focus_cursor",current_selection)
when you are doing the file select container and focus_cursor(current_choice)
when doing the confirmation dialog. In the call_deferred()
case, the Cancel label is drawn to the screen at (1,1)
scale, then the scale is set to (1.6, 1.6)
the drawing code recognizes this change and draws it with (1.6, 1.6)
scale.
In the direct call to focus_cursor()
the scale is set to (1.6, 1.6)
(AFTER the first idle frame AFTER the nodes have been instanced), the drawing code seemingly ignores this change and the Cancel label is drawn at (1,1)
scale. This behavior seems to contradict the documentation unless I am misunderstanding their usage of the term instanced
.
- If so, how does one go about tweening a Label's rect_scale if it is a
child of a container node? Is it just impossible?
I added a tween as a child node to the main control node of your project, stored it in the onready var tweeny
and modified your code this way:
func focus_cursor(selection:Control):
tweeny.interpolate_property(selection,"rect_scale",null,focus_scale,1)
tweeny.start()
As long as you call_deferred()
focus_cursor()
you see the see the effect of the tween. Interestingly enough, if you call focus_cursor()
directly, you don't see the effect of the tween BUT the scale is set to (1.6, 1.6)
which is.... just odd behavior to me.
Long story short if you want to change the rect_scale
of a Control
node that has a Container
for a parent always either set_deferred()
that property or call_deferred()
the function that handles the tweening of that property.