How to insert a new line using SetText or addStaticText?
How to insert a new line using SetText or addStaticText?
When setting text for the IGUIStaticText gui element, how do I insert a new line of text using addStatiText or setText methods?
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.
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.