I'll just add that I don't think we use getAttribute anywhere in the
system any more. Usually, but not always, our setters actually set a
property with the same name, so getting the property 'just works',
but sometimes the developer has not provided that, or the setter is
setting some internal runtime property that does not permit a simple
shadow.
[As Henry mentioned, there is a plan to support the propose getter
and setter functions in Javascript. That would mean that you would
no longer need to use setAttribute (or getAttribute), but you also
would need to use a separate property for storing state, unlike our
current convention.]
On 2006-05-16, at 21:07 EDT, Henry Minsky wrote:
> On 5/16/06, Philip Romanik <[EMAIL PROTECTED]> wrote:
>>
>> Hi Henry,
>>
>> Here's one example I've been trying to figure out. I don't know
>> whether
>> this is a documentation issue or a coding issue. The docs list
>> many items
>> as a 'setter'. Sometimes this means you can use them as a getter
>> too, but
>> other times you cannot.
>>
>> For example, you can get the opacity from a view, but you cannot
>> get the
>> motion from an animator. Both are listed as a 'getter' in the
>> documentation.
>>
>>
>> <canvas debug="true">
>> <view id="view1" bgcolor="red" width="200" height="200">
>> <simplelayout axis="y" spacing="10"/>
>> <animator id="a1" motion="linear" attribute="x" from="50"
>> to="100"
>> duration="500" start="true"/>
>>
>> <text text="${'opacity is ' + view1.opacity}" resize="true"/>
>> <text text="${'motion is ' + a1.motion}" resize="true"/>
>>
>> </view>
>> </canvas>
>>
>> If you run this example, it will show the motion as 'undefined'
>> rather
>> than
>> 'linear'. This isn't surprising because the object does not store the
>> motion type; it only saves the derived quantities.
>>
>> My questions are:
>> - Should I be able to read back the value of any 'setter'?
>
>
>
> No I don't think so, a setter only defines the API to set the value. A
> getter
> would compute and return a value. The 'motion' having a setter but
> no getter
> sounds like a bug to me, maybe Bret or Adam would know?
>
> - Should the docs indicate the relevant properties as getter/setter?
>
>
> I'm not sure. I would think that would be transparent to the user,
> as long
> as they used the setAttribute API. But in reality, its faster to
> set a slot
> directly in some cases using "foo.bar = xxx" and I'm not sure what
> our
> current 'best practice' is regarding this. I think anything exposed
> to the
> end user should be via the setAttribute/getAttribute mechanism.
> (Anyone want
> to chime in here?)
>
>
> Our getter/setter methods are designed to work via the
> setAttribute/getAttribute API. There is some proposal for setters and
> getters in the ECMAScript language spec but we don't support those
> at this
> time.
>
>
> Thanks!
>>
>> Phil
>>
>>
>>
>>
>
>
> --
> Henry Minsky
> Software Architect
> [EMAIL PROTECTED]
_______________________________________________
Laszlo-dev mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-dev