PDA

View Full Version : Consecutive wrapping text elements?


TheCatWhisperer
01-09-2004, 09:55 AM
Hi,

I'm try to get text elements to do somthing that seems rather simple.. I have a dataset that containes news information, and I want the pieces of information to display in this way:


{News Header} ({Source}, {Datestamp})
{Summary}

Example:
US soldier killed in Iraq mortar attack (ABC News, 1-8-2003 13:41)
A US soldier was killed and 34 others wounded when rebels fired mortar rounds at a military base near the Iraqi capital, Baghdad, last night, according to the US military.


This is the code I'm using to try and do this:


<view name="newsList">
<simplelayout axis="y" />
<view name="rowOfData" datapath="news:/news[1]/newsitem">
<wrappinglayout axis="x" spacing="3" />
<text datapath="slug/text()" />
<text datapath="source/text()" />
<text datapath="timestamp/text()" />
<text datapath="summary/text()" />
</view>
</view>


When this code evaluates it prints out:


US Soldier Kill i
ABC News
1-8-2003 13:41
A US soldier was

The truth is out T
Toronto Star
1-8-2003 13:43
It is disturbingly


It's not only not wrapping the items, but it is also cutting them off after 100 pixels?? Help??

/c

antun
01-09-2004, 11:19 AM
Here's how Laszlo text fields size: If you hard code text into a text field, then the text will be put there at compile-time, so the text field will automatically be resized to fit all your text.

If you declare a text field and datamap it (or just leave it blank with the intention of calling setText() later), you need to either decide on a fixed width, or use the resize="true" attribute of the text field to tell it to autofit its contents whenever they change. The latter method can be heavy on the processor if you end up with lots of replicated text fields, so be aware of that.

As for why it's not wrapping, it might be that this view:


<view name="rowOfData" datapath="news:/news[1]/newsitem">


... is only sizing to 100px, because the text fields are only 100px. If you set the width explicitly, it should fix the problem. If it doesn't, post a snippet of your data and I'll have a look.

-Antun