[Laszlo-dev] constraints firing too early

Henry Minsky henry.minsky at gmail.com
Tue Mar 29 07:27:48 PST 2005

I came across a case when debugging a demo app today where a debugger
warning is printed
due to a constraint executing before the view that it references has
been created.

            <mouseview resource="info_butt" onclick="classroot.getInfo()" 

The problem is that the view 'wish' apparently does not exist or has
not been added to the
parent's list of children yet when this constraint is first evaluated.
The sibling view "wish" in fact is declared just beneath the view that
references it:

        <view y="${classroot.cover.height + 8}" 
              x="${classroot.info.width &gt; this.width ?
classroot.info.x : 0 }"
            <simplelayout axis="x" spacing="4"/>
            <mouseview resource="info_butt" onclick="classroot.getInfo()" 
            <mouseview resource="cart_butt" width="54" height="18"
            <mouseview resource="wish_butt" width="54" height="18"
                       visible="${x + width &lt; classroot.width}"

As a workaround, I did this:

            <mouseview resource="info_butt" onclick="classroot.getInfo()" 
                       visible="${parent['wish'] ? parent.wish.visible
: false}"/>

But I wonder if there is some better way to deal with this situation. 

Henry Minsky
Software Architect
hminsky at laszlosystems.com

More information about the Laszlo-dev mailing list