Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
bbj
Contributor
bbj
Posts: 43
Registered: ‎02-22-2012
My Device: Developer
Accepted Solution

Is there any way of forcing line breaks in SystemDialog body text...

As per title

 

Any way of forcing line breaks in SystemDialog body text ?

 

Tried putting \n in the text + the \n simply gets displayed.

 

Dont appear to be ablet to put break tags in the text - the momnetics language resource file destroyer does not like the tags .

Retired
erahnenfuehrer
Posts: 85
Registered: ‎05-25-2012
My Device: Limited Edition Z10

Re: Is there any way of forcing line breaks in SystemDialog body text...

This worked for me:

 

body: "Message Body \n blah\n\nNewlines FTW!"

 

Are your SystemDialogs being displayed correctly?  Look at http://supportforums.blackberry.com/t5/Cascades-Development/How-to-remove-Cancel-button-in-SystemDia... for reference.

bbj
Contributor
bbj
Posts: 43
Registered: ‎02-22-2012
My Device: Developer

Re: Is there any way of forcing line breaks in SystemDialog body text...

Thanks for the hint!

 

What seems to be going on is

 

i) if you pass the setBody() method a string literal - as in setBody("line1 \n line 2") all is well

ii) from prev poster, if you set body text via a QML file the \n is processed correctly (not verified, but believe prev poster)

 

HOWEVER

 

If you load the text from a TS file, as in setBody(QApplication::translate("","String Reference")); and the string in the TS file contains the \n characters - the new line does not appear - the '\' and 'n' chars are displayed instead. This is despite the procecssing of the TS files

 

To have newlines in the TS file use the 
 encoding (instead of the \n)

 

Note. The TS file mangler will proceed to mangle your TS file containing the 
 and replace it with an actual new line in the xml text - so that may well be the alternate soln - simply put a new line in your text. But relying on some dubious bit of xml file text formatting seems unreasonable.....

 

So weve gone for a %argNum approach and used a QString.arg()

E.g.

LineOne%1LineTwo

and used a String str = tsFileString.arg(QString("\n"));

 

as we already have to use the QString.arg() on this particular string anyway.