i believe this will do it. I had this problem once, the issue is that the text has no inherent height until after it's is laid out -- which is after the view gets it's size, so the solution is to use the onheight handler of the text that gets called when the text height changes (gets laid out), and there is your chance to set the height of the parent view. This is also dynamic to changing text sizes...

-  The view's width is set to make the text wrap.
-  The text field is set to multiline and given text that will wrap.
-  A handler is made on the text so that when the height of the text changes, this will change the height of the parent view.

<view bgcolor="red" width="100">
<text multiline="true" name="field" width="${parent.width}">
<handler name="onheight">
parent.setAttribute('height', this.getTextHeight());
</handler>
hi there world
how are you?
i am fine.
</text>
</view>

Voila! Let me know if that works.. enjoy.


(output picture attached)

Attachment: Picture 1.png
Description: application/applefile

<<inline: Picture 1.png>>


On May 28, 2007, at 1:17 PM, petergien wrote:


How can I tie the height of a view to be equal to the height of some
multiline text that wraps inside the view. The view will have a fixed width.
The text varies in length and may occupy 1 to 5 lines when wrapped inside a
view. 

Thanks
-- 
Sent from the OpenLaszlo - User mailing list archive at Nabble.com.


Reply via email to