0 votes

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_

Godot version 3.3
in Engine by (26 points)

1 Answer

+1 vote
Best answer

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.

by (8,546 points)
selected by

This worked, thanks so much!

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.