Godot 4.0.2
In my project I'm making a basic tooltip which can be applied to anything really. Move your mouse cursor over an object -> get a tooltip. Everything works fine, until the tooltip is displayed. Without playing with its custom_minimum_size
all I get is a tall 1px wide line (basically, the contents of the RichTextLabel
I use get squished inside the parent PanelContainer
(at least, I assume it does that)). However, if I manually set the aforementioned custom_minimum_size
of PanelContainer
- things get displayed correctly, with one condition - I can't use RichTextLabel.size
property for that. If I do, I get the same result as it was - tall 1px wide line. Oh, and the RichTextLabel
is set to fit_content
. I tried changing RichTextLabel
size_flag
s (tried every one) - didn't do anything.
In addition, if it matters:
PanelContainer
RichTextLabel
with necessary contents as a childPanelContainer
as a child to the get_tree().get_root()
(as I am testing it in a separate scene, the root is a Control
node)Change the RichTextLabel.autowrap_mode
to TextServer.AUTOWRAP_OFF
.
The default for RichTextLabel
is AUTOWRAP_SMART
which does not play well with containers, resulting in 1px wide labels.
See AutowrapMode for the list of modes, others may fit better for your use case. You may need a combination of minimum size and autowrap mode for it to work as desired.
This can be done through gdscript with:
my_label.set_autowrap_mode(TextServer.AUTOWRAP_OFF)
Or in the node inspector: