Detect mouse hover on specific parts of text in RichTextLabel?

Godot Version

4.3.stable

Question

I’m trying to do an interface where you can hover over specific parts of a text to make something happen, hoping to find a way where I don’t need to build a calculation for the positions myself. (Line breaks would make that especially painful…)

The way the “hint” BBCode tag is handled suggest there’s some logic in place that lets Godot know when a section is hovered over, but is there any way to make use of this for anything more customized?

rich text label docs

bbcode docs

richtext has the signals finished, meta_clicked, meta_hover_start and meta_hover_ended
they pass an argument with what has been clicked/hovered over


func _richtextlabel_on_meta_clicked(meta):
	# `meta` is of Variant type, so convert it to a String to avoid script errors at run-time.
	OS.shell_open(str(meta))

the bbcode documentation says url can be used with meta_clicked
[url={"example": "value"}]JSON[/url]

1 Like

Oh thanks, this is splendid. I should have searched more thoroughly, somehow I got bugged down trying to find the answer on the BBCode page.