[Laszlo-dev] measureWidth and measureHeight functions

Sarah Allen sallen at laszlosystems.com
Sun Jun 22 20:57:56 PDT 2008


I think your clarification is a good one.  Thanks for updating the docs, 
along with fixing the bug!

Sarah

P T Withington wrote:
> [Redirecting to laszlo-dev]
>
> From the documentation (and the implementation) it appears that the 
> intent of measure* is to measure the dimensions the view _would_ have 
> if the view did _not_ have an explicit dimension.  That is, in your 
> test case, if I were to say:
>
> <view id="a" width="0" height="0">
>    <view width="100" height="100"/>
> </view>
>
> or:
>
> <view id="a" width="500" height="500">
>    <view width="100" height="100"/>
> </view>
>
> a.measureWidth() will still return 100.  If the view has no explicit 
> dimension, then it should be the case that the actual and measured 
> dimension are the same.
>
> I just want to clarify that point, because you said "it should be the 
> total width of views and subviews", whereas I think a better way of 
> saying it is "it is the _natural_ width of the view and its subviews".
>
> I have a fix for the bug that was causing measure* not to work when a 
> view has no resource assigned (default the resource dimensions to 0 
> not null).  I also am updating the code to actually use the same 
> measurement algorithm used to default the dimensions of a view (which 
> takes rotations into account).  But I'd like to make the documentation 
> a little clearer.  This is my proposed documentation:
>
> /**
>   * Reports the "natural" width of the contents of the view. That is,
>   * the width the view would have if it did not have an explicit
>   * width.
>   *
>   * (Note: this method is not supported in a constraint expression.)
>   */
>
> Okay?
>
> On 2008-06-19, at 00:47 EDT, Sarah Allen wrote:
>
>> it should be the total width of views and subviews, e.g.
>>
>> <view id="a">
>>    <view width="100" height="100"/>
>> </view>
>>
>> a.measureWidth() should return 100
>> a.width will be null (or at least it was in 3.x)
>>
>> P T Withington wrote:
>>> The best I can suggest is to compare to the 3.x release/doc.
>>>
>>> On 2008-06-18, at 17:52 EDT, Matt Wilde wrote:
>>>
>>>> The measureWidth and measureHeight functions return null unless a 
>>>> resource is attached to the view you're calling them on. Is this 
>>>> the expected behavior of these functions?
>>>>
>>>> I'm trying to fix a sample which acts as though these functions 
>>>> should return the total width of the view and its subviews, even if 
>>>> there is no resource attached to the view in question.
>>>>
>>>> Thanks,
>>>> Matt Wilde
>>>
>>
>



More information about the Laszlo-dev mailing list