+1 vote

I currently have a project that has a RichTextLabel that displays text. Some of the text we display has BBCode for URLs ([url=someUrl]Text[/url]) and then we have a script on the node containing the label:

func _on_text_meta_clicked(meta):

The label has a connection to that method and it works wonderfully when we run the project directly from the Godot editor or from a runnable .dmg file on our Macs. I exported the project to HTML5, uploaded it to a server, and noticed that the links do not work. I'm assuming the issue is the reliance on OS, but would like to have this work in both cases. Is there another class I can use and a method I can call to check how the project is running to see if I should use OS or the other class at runtime?

in Engine by (13 points)

1 Answer

+2 votes

This worked for me:

func _ready():
    if OS.get_name() != "HTML5":
        $RichTextLabel.connect("meta_clicked", self, "_on_RichTextLabel_meta_clicked")

func _on_RichTextLabel_meta_clicked(meta):

Basically, if it's HTML let the browser handle the call (by doing nothing). If it's not HTML, hook up the meta_click signal manually in the _ready function for any OS and make the OS call the url using the shell_open function.

This might be a year after you asked, but I was looking for the same thing and your question gave me the idea of using the meta_click function to solve my issue of running on the OS (so opposite of the issue you had).

So hopefully this helps someone else.

by (24 points)
edited by
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.