PDA

View Full Version : tabelement question


jhambley@mac.co
03-30-2004, 07:26 PM
Using the following code, the output to the video tab is trauncated on the right hand side. Can you provide some insight as to why that is happening.

Here is the code:

<canvas bgcolor="#EEEEEE" height="600" width="800">

<dataset name="vs">
<VideoSegments>
<video>
<title>Getting Started with Laszlo</title>
</video>
<video>
<title>Working with Views</title>
</video>
<video>
<title>Laszlo Components</title>
</video>
</VideoSegments>
</dataset>

<window>
<tabslider width="250"
height="200"
spacing="2" slideduration="100">
<tabelement text="Documents"/>
<tabelement text="Audio" />
<tabelement text="Video">
<view datapath="vs:/VideoSegments">
<text datapath="video/title/text()"/>
<simplelayout axis="y"/>
</view>
</tabelement>
<tabelement text="Items For Purchase" />
<tabelement text="Links" />
</tabslider>
</window>

</canvas>

antun
03-31-2004, 09:18 AM
The reason it's getting cropped is because the text fields are not wide enough. See, if you write a text field with text inside of it already (<text>foo</text>) it will be generated when the app is compiled and the text field will be the correct size. Now if you bind it to data like you've done, it has no text in it at compile time, and it defaults to the default width for a text field (100px), so when the text gets set the field is still too small.

A good way of debugging in Laszlo is to give things background colors. You'd be able to see what was wrong immediately if you did:


<text bgcolor="yellow" datapath="video/title/text()"/>


Now to fix the problem either give the text field a width:


<text width="200" datapath="video/title/text()"/>


... or constrain it to something like its parent:


<text width="$once{parent.width}" datapath="video/title/text()"/>


... or use the resize attribute which recalculates the text field's width every time text gets set:


<text resize="true" datapath="video/title/text()"/>


You might want to avoid over-using resize, since a lot of text views that are resizing all the time can be a performance hit.

-Antun