0 votes

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?

asked Jun 20, 2019 in Engine by Serneum (12 points)

1 Answer

0 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.

answered Jun 16 by ElectronicArmory (20 points)
edited Jun 16 by ElectronicArmory
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 How to use this Q&A? before posting your first questions.