[Laszlo-dev] For Review: Change 20061211-Philip-6 Summary: Modify l-in-10 scripting->event application
P T Withington
ptw at openlaszlo.org
Mon Dec 11 14:25:02 PST 2006
So take my suggestion to toggle the color according to whether the
window is wide or not. (Since your suggestion doesn't.)
I would _still_ like the example to point out that `onwidth` _will_
be called when the width is initially set. You could make this even
clearer, by not having an initial bgcolor on the view:
<canvas layout="axis:y;spacing:5">
<button onclick="vw.setWidth(200)">Big</button>
<button onclick="vw.setWidth(100)">Small</button>
<view id="vw" width="100" height="100">
<!-- onwidth is sent anytime width is changed -->
<handler name="onwidth">
this.setAttribute('bgcolor', this.width > 100 ? red : blue);
</handler>
</view>
</canvas>
Is this horse dead yet?
On 2006-12-11, at 17:05 EST, Jim Grandy wrote:
> Well, we all know what happens with sample code -- it gets copied
> and extended. We're embedding a gotcha in this example that will
> hit anyone who blindly copies it and tries to make something more
> complex. I think that's a bad choice from a pedagogical point of view.
>
> jim
>
> On Dec 11, 2006, at 2:00 PM, P T Withington wrote:
>
>> There is no code in the example to set it back.
>>
>> If that is what you want to demonstrate, use something like:
>>
>> this.setBGColor(this.width > 100 ? blue : red);
>>
>> and add another button. But I like the current example's setup
>> because it brings up the issue of handlers having to verify their
>> pre-conditions (as I said in previous mail).
>>
>> On 2006-12-11, at 16:29 EST, Jim Grandy wrote:
>>
>>> The problem is this won't work if you try to set the width back
>>> to 100.
>>>
>>> Can you use something like
>>>
>>> if (this.isinited == false)
>>> return;
>>> this.setBGColor(0xFF0000);
>>>
>>> ?
>>>
>>> jim
>>>
>>> On Dec 11, 2006, at 1:08 PM, Philip Romanik wrote:
>>>
>>>> The latter. The behavior is now consistent between swf and
>>>> flash, but with the current initialization, the onwidth() event
>>>> turns the box red immediately. The box should be blue until the
>>>> user clicks on the button.
>>>>
>>>> This change makes the initialization order moot.
>>>>
>>>>
>>>>> This was not fixed by Henry's event deferral patch?
>>>>>
>>>>> Or are you saying that the behavior is now consistently not
>>>>> what is
>>>>> desired on both platforms?
>>>>>
>>>>> On 2006-12-11, at 15:54 EST, Philip Romanik wrote:
>>>>>
>>>>> >
>>>>> > Change 20061211-Philip-6 by Philip at Philip-DC on 2006-12-11
>>>>> 15:42:37
>>>>> > EST
>>>>> > in /cygdrive/f/laszlo/svn/src/svn/openlaszlo/branches/legals
>>>>> >
>>>>> > Summary: Modify l-in-10 scripting->event application
>>>>> >
>>>>> > New Features:
>>>>> >
>>>>> > Bugs Fixed: LPP-3247
>>>>> >
>>>>> > Technical Reviewer: ptw
>>>>> > QA Reviewer: (pending)
>>>>> > Doc Reviewer: (pending)
>>>>> >
>>>>> > Documentation:
>>>>> > The existing app doesn't work as intended because of an
>>>>> > initialization issue. The onwidth() event is fired during
>>>>> > initialization and this turns the view blue. The intent of
>>>>> the demo
>>>>> > is to show an event being fired when the user clicks on a
>>>>> button.
>>>>> >
>>>>> > My first thought was to make sure the object was fully
>>>>> initialized
>>>>> > before enabling the onwidth event. The problem is that it
>>>>> will make
>>>>> > the app look more complicated. I took an easier route and
>>>>> changed
>>>>> > the onwidth() method to only turn the view red if the size
>>>>> changes
>>>>> > from the initial value. There are lots of ways to solve this
>>>>> issue
>>>>> > and the simplest is to hard-wire the initial width into a
>>>>> > conditional. I changed
>>>>> >
>>>>> > <handler name="onwidth" >
>>>>> > this.setBGColor(0xFF0000);
>>>>> > </handler>
>>>>> >
>>>>> > to
>>>>> >
>>>>> > <handler name="onwidth" >
>>>>> > if (this.getWidth() != 100)
>>>>> > this.setBGColor(0xFF0000);
>>>>> > </handler>
>>>>> >
>>>>> > This change requires no explanation to the reader.
>>>>> >
>>>>> > Release Notes:
>>>>> >
>>>>> > Details:
>>>>> >
>>>>> >
>>>>> > Tests:
>>>>> > Run l-in-10 scripting->events in swf and flash
>>>>> >
>>>>> > Files:
>>>>> > M laszlo-explorer/scripting/events.lzx
>>>>> >
>>>>> > Changeset: http://svn.openlaszlo.org/openlaszlo/patches/
>>>>> 20061211-
>>>>> > Philip-6.tar
>>>>> >
>>>>> >
>>>>
>>>
>>
>
More information about the Laszlo-dev
mailing list