Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Macryc |
Hi!
I’m having a problem with assigning a function to clickable text inside of a RichTextLabel. My label is bbcode enabled. I’m able to get the text to be underlined and clickable by doing this:
label.bbcode_text = '[url="function_to_call"]Clickable text[/url]'
But then I get stuck. I know there is a meta_clicked signal that this emits but I can’t get it to work. I want function_to_call()
to be called when the clickable text between url tags is clicked. What is the correct syntax?
You mean something like that?
extends RichTextLabel
func _ready():
bbcode_enabled = true
bbcode_text = '[url="function_to_call"]Clickable text[/url]'
func _on_RichTextLabel_meta_clicked(meta):
function_to_call()
func function_to_call():
print("Label has been clicked!")
juppi | 2020-05-27 18:24
Doesn’t work. Also, why would you need this:
func _on_RichTextLabel_meta_clicked(meta):
function_to_call()
This to me looks like an auto generated function when connecting meta_clicked in the editor. This will not work for me as I am assigning the text from a remote script and the function I want to call is also in that remote script.
Macryc | 2020-05-27 18:46
OK here’s what i ended up doing and it worked:
func _ready():
label.connect("meta_clicked", self, "label_clicked")
func some_other_func():
label.bbcode_text = '[url="do_something"]Clickable text[/url]'
func label_clicked(do_something):
do something
Macryc | 2020-05-27 18:50