Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | pferft |
Hi everyone,
I have a RichTextLabel set up including:
export (NodePath) var pre_comma_digits
...
var leftandrightofcomma = text.split(",", true, 1)
get_node(pre_comma_digits).text = leftandrightofcomma[0]
So whenever I put some numbers in, they appear correctly in my PreCommaDigits-RichTextLabel as well. (The post-comma digits appear in another Label…)
With Bb Code I’d like these numbers to be aligned right, so within PreCommaDigits I coded:
extends RichTextLabel
var templateAlwaysAllRight = "[right]{content_to_align}[/right]"
func _ready():
var the_numbers = self.text
bbcode_text = templateAlwaysAllRight.format({ "content_to_align": the_numbers })
I wrote “PRE” in the Bb Code textfield in the editor and this really is right-aligned at start. However, as soon as I enter numbers, they are displayed left aligned.
I tried things like
label.push_align(RichTextLabel.ALIGN_RIGHT)
label.append_bbcode(self.text)
or
label.bbcode_text = "[right]{replaceThis}[/right]"
label.bbcode_text = label.bbcode_text.format({"replaceThis":self.text})
and alike but all to no avail.
I’m not sure why this happens, but I assume I’d somehow need to get the “dynamically entered” numbers into a variable to be put into the right place then.
How could that be done? Any suggestions are much appreciated!