Can't reset the size of a RichTextLabel

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

I’m trying to implement custom tooltips into my game, because I need rich text on mine and Godot’s default tooltips only allow for unformatted text. Right now, my approach is simple: the tooltip is a PanelContainer with a child RichTextLabel, which follows the mouse with a small offset. Objects that use the tooltip call a function to show text on it on the mouse_entered signal, and call a function to hide it on the mouse_exited signal.

This system mostly works, but with one flaw. If users mouse over from a tooltip with a lot of text to one that has less, the tooltip will still be the same size - but curiously, only for the first time. If you then mouse off the smaller object and back on, it displays with the correct size.

Mousing onto the first object

Mousing onto the second object; the tooltip is too big

Mousing onto empty space, then back onto the second object; the tooltip is now the size it should be

Minimum reproduction project is here: https://drive.google.com/file/d/1u6usZTJ8lo8pb4_zt0YQM93dA0FbMSB_

:bust_in_silhouette: Reply From: exuin

Switch line 22 and 23 of Tooltip.gd.

show()
rect_size.y = 0

This will set the size to 0 after the tooltip appears. I guess the size doesn’t properly update until the tooltip is visible.

This worked, thanks so much!

Void | 2021-06-22 06:07