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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Contributor
Posts: 19
Registered: ‎07-12-2012
My Device: 9700, Playbook 16GB, and Dev Alpha
My Carrier: Starhub
Accepted Solution

Escaping \n (New Line) only prints it

Hi, I have simple problem here:

I have a ListView that when selected will push NavigationPane with a long description on it.

 

The long description is stored in dataModel which also contain title for the list.

 

The problem is the \n (New Line) inside the description is literally printed as "\n" and not making a new line.

 

I tried  typing "Hello\nWorld" inside TextArea.text and it does create new line.

 

So, what's the problem here? Any solution? Thanks

Contributor
Posts: 19
Registered: ‎07-12-2012
My Device: 9700, Playbook 16GB, and Dev Alpha
My Carrier: Starhub

Re: Escaping \n (New Line) only prints it

Hi, I manage to find a way to solve this by literally add new line in the dataModel.

 

For example:

<root>
    <header title="Group 1" >
        <item title="Item 1" description="1. Hello
2. World
3. Bye!" />
    </header>

 This way, the code become messy. Is there any better solution?

Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: Escaping \n (New Line) only prints it

[ Edited ]

Hi,

'\n' resolves to single character with ASCII code 10.

\n in dataModel text is two characters and not the newline.
How do you create and populate the dataModel?

 

upd:

This code in XML should be equivalent to '\n' in C++ code but regular newlines will also stay:

&#10;

 

Another option is loading XML manually using QXmlStreamReader, replacing newlines with spaces and "\n"-s with newlines, then adding the data to GroupDataModel or ArrayDataModel. XmlDataModel is not very flexible and doesn't allow editing of it's data.

 


Andrey Fidrya, @zmeyc on twitter
Contributor
Posts: 19
Registered: ‎07-12-2012
My Device: 9700, Playbook 16GB, and Dev Alpha
My Carrier: Starhub

Re: Escaping \n (New Line) only prints it

Thanks &#10; does work to replace new line

For now, the data model is still hard-coded. User will be able to add more list later.

 

By the way, is there easy way to create ordered list / numbering? I prefer doing it in QML than C++.

Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: Escaping \n (New Line) only prints it

I think ordered list can be implementing by creating a custom ListItemComponent with a Label inside. Bind the label's text to current item's index. It can be accessed as ListItem.indexInSection.

Please create different threads for each question. Smiley Happy

Andrey Fidrya, @zmeyc on twitter
Contributor
Posts: 19
Registered: ‎07-12-2012
My Device: 9700, Playbook 16GB, and Dev Alpha
My Carrier: Starhub

Re: Escaping \n (New Line) only prints it

Okay Thanks a lot