How to insert a new line using SetText or addStaticText?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Weng
Posts: 97
Joined: Tue Oct 03, 2006 4:23 pm
Location: Singapore

How to insert a new line using SetText or addStaticText?

Post by Weng »

When setting text for the IGUIStaticText gui element, how do I insert a new line of text using addStatiText or setText methods?
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

You want to add a new line to a current IGUIStaticText element?

So you might have 'Hello world' displaying in a static text element and then you want to add a new line saying 'How are you?' to it so it reads like this:

Hello world
How are you?

Is that right?

What you could do is use a second static text element and simply place it underneath.

Or you could get the text from the current static text element and then append the second line on and then re-set the text.

Something like this i guess:

core::stringw str = text->getText();
str += L"\nHow are you?";
text->setText(str.c_str());

You may have to check up the API for stringw and IGUIStaticText to make sure of the correct functions, but that's the idea.
Image Image Image
Weng
Posts: 97
Joined: Tue Oct 03, 2006 4:23 pm
Location: Singapore

Post by Weng »

I added '\n' and it works.....thanks~ :D
Post Reply