How to Add a Line Break to RichTextLabel "Bbcode"

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By davidpgil
:warning: Old Version Published before Godot 3 was released.

I have a line of text in the RichTextLabel Bbcode field that reads:

[center]TM AND ©1989\nCAPCOM U.S.A, INC.\nLICENSED BY\nNINTENDO OF AMERICA. INC.[/center]

My issue is I can’t get the line break/ new line to happen. As you can see I tried typing “\n” and have also tried “\r” which are common ways to do this in C-like languages. How can I get my line of text to appear in my app like the following?:

TM AND ©1989
CAPCOM U.S.A, INC.
LICENSED BY
NINTENDO OF AMERICA. INC.

If I need to use GDScript; I am new to GDScript, so example code is welcome. Thanks in advance for your assistance.

:bust_in_silhouette: Reply From: wombatstampede

Hi again!

“\n” is the way to go:

get_node("RichTextLabel").set_bbcode("Hello\nWorld!")

Displays here (Godot 2.1.4) a text with a line feed.
When initializing the text with content from translation csv-files (no auto-init here I think)

I.e.:

get_node("gui/pnlHintHint/label").set_bbcode(tr("KEY_HINTHINT"))

I have a hex 0A in the csv-file for translation. (As done by open calc which I use as csv-editor).

When you want to set the linefeed directly in the godot editor (without gdscript) then just click the little icon right of the bbcode value field. A multiline editor will open where you can simply enter line feeds by pressing return.

Thank you! You’ve been giving me an excellent impression of the Godot community!

The GUI based solution is what I need now - that worked.

Regarding the translation csv stuff. I’m not there yet. I will definitely favoritye your response though because I do intend to work with dynmaically loaded text in the future.

Thanks for including the GDScript solution. I suspect I will be needing that soon.

Best regards on the crunchy response. I hope that I may be able to help others as I begin stepping up. Cheers!

davidpgil | 2017-10-09 08:18