How to add line break in strings?

Hi there…I implemented tooltip display in my [RTS Game][1] but i need line breaks in my string. Using < br > or /n does nothing. Any idea how can i get line break in strings using Blueprint?

Here is an example BP Graph:

Hi Ryan, from what I can tell it looks like we don’t have a way for you to input special characters in these fields. We don’t process each string for \n or any of the other C++ special escaped characters on compile of the nodes. Arguably we should…

Take a look at the Blueprint Office sample, that has the floating tooltips. They solve the problem by having an array of text, each index representing a line. They process the array and a new text renderer is spawned at some offset to create multiple lines.

Awesome work so far on the blueprint only RTS.

Cheers,
Nick

Hi Nick,

But i dont want to use Text Renderer. I am using Draw Text in HUD class to draw the tooltips. Using < br > on Text Renderer Set Text works but for Draw Text it doesnt. Does Epic plan to address this issue anytime soon? I really need this to work with Draw Text otherwise i’ll temporarily remove drawing Tooltips for now. I tried Parse Into Array node and it does break the strings into new lines but there is no space in between them.

And Thank You very much for the comment on my RTS Game. Happy to hear that! :smiley:

Any news on this?

You can add newlines to text and string in blueprints by using Shift+Enter when typing into the fields. (in 4.8)

3 Likes

This doesn’t work for me in 4.8.0. When I press Shift+Enter in a string variable field, nothing happens. \n and <br> also don’t work.

I tried Shift+Enter and it doesn’t work. I’m doing this in the Localization Dashboard. In first 4.8 I got this to work with \n but now that doesn’t work at all. If it’s declared in code it works however with \n .

I’m also looking for an option to do this.

I see this question is kinda old, but I would just like to add my 2 cents. I overcame this issue by typing my text in notepad with all the spaces and paragraphs I needed, and then pasting that into a Make Literal Text module. Then I used that to set my text variable. It saves all the spaces and line breaks. Maybe it should work for strings as well.

YES!!! Magnificent. Shift-Enter puts a CarriageReturnLineFeed char :slight_smile:
Thanks again Nick.

Shift-Enter doesn’t work for me either. In 4.10.2, are you typing into a text variable in a blueprint, Maha Vajra?

The SHIFT-ENTER line feed does not work in a variable of text or string it seems, only a text box in UMG

shift + enter

b3174182ac

4 Likes

Shift+Enter !
It works! String in Blueprint

It worked for me! Thanks!

I found an option inside the string variable in the Advanced Label, “multi Line” if you check it, then you can add a line break, using Alt+Enter Hope this works for new people who have this issue.

It works fantastic with shift+enter in ue5.2 when using strings, thanks!

1 Like