Normally I do

TooltipNode.hint_tooltip = "Line 1 Text" + "\n" + "Line 2 Text"

How can I set "Line 1 Text" to bold or centered? I know that bbcode for this has to be [b]some string[/b] and [center]some string[/center]. If I try this, it does not work:

TooltipNode.hint_tooltip = [center]"Line 1 Text"[/center] + "\n" + [b]"Line 2 Text"[/b]

Do the tooltips even support BBcode on their own? Might need to use a RichTextLabel for it perhaps?

I haven't really looked into tooltips in godot before, so I'm not sure either, but I wouldn't be surprised if they don't support BBCode out of the box.

This is assuming you are willing to implement a custom node for a tooltip. Basically build a RichTextLabel based node structure to show up on mouse hover over an element displaying your BBCode hint in return.

I did some research, and it appears that Tooltips may have some support for some BBCode tags, or BBCode like tags. One of the most common tags is the [code][/code] tag, as seen in issue 19084 and 24926. I have no idea if custom Tooltips can have these tags.

In issue 19084 it is mentioned that custom tooltip support would be needed. Apparently formatting and tags should be working in Tooltips. The only place I found in the source code that suggests it might be possible to use BBCode like [b] is this line in the editor inspector source code.

I have not really used Tooltips in Godot though, so I'm not sure what is doable or not. It seems there is some form of BBCode support, but it might be that this functionality is not exposed to GDScript and/or user defined Tooltips.


Edit: Hmm, after some testing, it seems none of the BBCode in the linked GitHub issues render correctly when applied to a Control node through the hint_tooltip property. I guess BBCode support for Tooltips is only available in the editor?

Using a custom node for in-game tool tips might be the best solution for proper BBCode support.


Edit 2: It looks like BBCode is not possible through Tooltips set in Control nodes, because the node used to display the Tooltip is just a normal Label node, not a RichTextLabel. After poking around in the source, I found the code that creates and populates the Tooltip for Control nodes.

In Viewport.h, line 267 defines the GUI struct that is used for Tooltips. On line 279 is the definition for the Tooltip label. The Tooltip label has it's text set on line 1462 of Viewport.cpp.

It looks like you'll have to use a custom node/scene for in-game tool tips if you want BBCode support within tooltips.

Thanks a lot for your answers. It actually seems that the tooltip is just a Label what is kind of frustrating and a bad design choice in my opinion.

What I wonder is, how can one underline a word in that tooltip? Isn't that bbcode [u][/u]?

Have not checked, but I'd expect godot engines tooltips, at least where relevant, to very much be based on rich text label. That is to say they likely are implementing a custom tooltip for it.

From what I found when poking around the source code, it seems the tooltips in the Godot editor use RichTextLabel nodes, while Control node based tooltips use just Labels. I think the Godot editor uses a different tooltip system and/or overrides the tooltips.

And once again: Thank you both for the answers. I then have to work myself into that custom tooltip topic.

4 days later

Some tooltips in the editor use the EditorHelpBit class, which is only available in the editor. It consists in a panel that contains a RichTextLabel where BBCode formatting can be used.

You can build the same functionality in your own project. In general, I would recommend doing this when you need to polish your tooltips with precise positioning, animations, …

3 years later