Text line breaks? (not strings)

I can’t figure out how to do the simplest things with display.newText. How do I get line breaks to work. \n isn’t doing anything and the docs have absolutely no info on this!

All the string formatting stuff looks neat on the terminal window, but I need it to show up on screen!

Any help would be greatly appreciated. [import]uid: 10835 topic_id: 4204 reply_id: 304204[/import]

i have the same Problem ! [import]uid: 22743 topic_id: 4204 reply_id: 20824[/import]

Use this:
http://developer.anscamobile.com/code/multiline-text-width-pixel

You can also use the code in:
http://developer.anscamobile.com/code/scroll-content

It breaks up long text into new lines. Then scrolls it as well. [import]uid: 8045 topic_id: 4204 reply_id: 21537[/import]

But let’s look at this simple. If I have:

local myTxt = display.newText("hello\nworld", 10, 10, native.systemFont, 10)  

… the newline does not get rendered. I get an output like:

helloworld  

So referring back to the OP’s question, how do newlines work in Corona. The Lua docs say to use ‘\n’ but that isn’t working with display.newText() [import]uid: 3365 topic_id: 4204 reply_id: 58295[/import]

Hey guys,

+1!

How to get the command “\n” to work?

Is there some other way to get it working?
Thanks. [import]uid: 89165 topic_id: 4204 reply_id: 58302[/import]

So Developers,

Is it impossible to get the \n working by any way?

I really do appreciate any reply about it.
Thanks,
Rodrigo. [import]uid: 89165 topic_id: 4204 reply_id: 58313[/import]

Here’s one way ive been doing multi-line text in an app im working on…

local address1 = "123 Road, Harrington, London, ST16 3lS"  
  
address1 = string.gsub(address1, ", ", "\n")  
  
local addressLabel = display.newText(address1, 0, 0, "Verdana-Bold", 16 )  
addressLabel.x = \_W/2+20; addressLabel.y= \_H/6;  
slideGroup:insert(addressLabel)  

Thats so that i can just type out one address, and it substitutes the comma’s for \n which then in turn creates the line breaks.

This works perfectly in my code, so i dont see why it wouldnt work for you! [import]uid: 69826 topic_id: 4204 reply_id: 58320[/import]

Ok ignore my above post…

I just built that to device and it doesnt add the new lines, despite working in the simulator.

The only option i can see now is to use the natve.newTextBox, which DOES allow the use of \n but unfortunetly isnt supported in the simulator. [import]uid: 69826 topic_id: 4204 reply_id: 58331[/import]

Thank you Jammy trying to let some help!

BUT that as you said just does not work also and the simples question is:

The command “\n” does not work totally?
Sorry guys, but that is really important for me right now.
Regards,
Rodrigo. [import]uid: 89165 topic_id: 4204 reply_id: 58438[/import]

Hey guys,

Yeah, \n is currently not useable - however this is not a permanent thing and it will get resolved in the near future.

In the mean time, you can use this; http://developer.anscamobile.com/code/auto-wrapped-text-updated

It works fine and I’ve been using it with a friend of mine (writer) who is writing a book app :slight_smile:

Peach [import]uid: 52491 topic_id: 4204 reply_id: 59062[/import]

Seems like this still doesn’t work. Anyone got an estimate on delivery? [import]uid: 91921 topic_id: 4204 reply_id: 92128[/import]

It does work now. See; http://developer.anscamobile.com/content/displaynewtext

You just have to specify width and height as well, not just X and Y.

Peach :slight_smile: [import]uid: 52491 topic_id: 4204 reply_id: 92135[/import]