Thank you James, it worked quite well. I printed out the getTextHeight() from
the onheight event in the debugger. I got three firings of the event, the
first one reports zero height, the second two are identical and report the
correct height. Setting the containing view height to this value works like
a charm.
And now on to my next challenge: The view that contains the text and that is
having its height adjusted is actually a node in a k_tree. Unfortunately,
k_tree uses a preset static height to space the nodes out in the y
direction. I have looked at the code in k_tree_controller.lzx where these
nodes are laid out according to a simple even spacing scheme. I need to make
the vertical spacing adjust according to the height of the individual nodes.
If anyone has done something like this, please share.
jamesr-2 wrote:
>
> 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)
> 
> 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
>> --
>> View this message in context: http://www.nabble.com/textheight-in-a-
>> multiline-text-view-tf3829056.html#a10839341
>> Sent from the OpenLaszlo - User mailing list archive at Nabble.com.
>>
>
>
>
--
View this message in context:
http://www.nabble.com/textheight-in-a-multiline-text-view-tf3829056.html#a10865514
Sent from the OpenLaszlo - User mailing list archive at Nabble.com.