That sounds like a good heuristic

On Mon, Sep 13, 2010 at 11:18 PM, P T Withington <[email protected]>wrote:

> At least in this particular case, it's interesting that the programmer
> explicitly said `text=""` in the open tag.  I think we could say that if you
> explicitly assign the text attribute, whether in the open tag as is done
> here, or as an explicit attribute tag, then the compiler should _not_ try to
> interpret the body of the tag as the text value.  That would seem to give an
> easy out for the case where you want to make a one-off text instance with
> methods -- you just specify the content as the initial value of the text
> attribute instead.
>
> How does that sound?
>
> On 2010-09-13, at 22:34, Henry Minsky wrote:
>
> > Note that this particular <text> view occurs inside of a class definition
>  (
> > the "<photo>" class), so if you can't add methods to the <text> instance,
> > you need to put your new one-off class
> > outside the parent class def someplace, which kind of un-localizes the
> > source code in an annoying way.
> >
> > This seems like a sort of special case worth handling, where the user has
> a
> > <text> view
> > which does not have any initial text content, but does have a bunch of
> > custom methods
> > or handlers that want to go into it.
> >
> > So my solution would be that if the compile-time text content has zero
> > length (with whitespace normalized away), then the compiler won't
> complain
> > about LZX tags in the content.
> >
> > On Mon, Sep 13, 2010 at 10:27 PM, Henry Minsky <[email protected]
> >wrote:
> >
> >> Just a real world example here. I added the warning to the text content
> >> collector, and tried compiling some of the demos.
> >>
> >> I got a warning from lzpix, which referred to this text view in
> >> demos/lzpix/classes/photo.lzx
> >>
> >> Sure enough it's a text view instance which contains a bunch of LZX
> methods
> >> and handlers.
> >> So our recommendation in this case is to create a one-off class or a
> >> mixin?
> >>
> >>     <text text="" width="100" fgcolor="0x1b1191" fontsize="10"
> >>              y="${classroot.height + 3}"
> >>              name="txt" visible="false"><!-- Setting this initially to
> >> false
> >>              seems to fix a visual issue where these would cluster on
> the
> >>              upper left of the page in DHTML. -->
> >>            <handler name="ontext">
> >>                this.adjustDimensions();
> >>            </handler>
> >>            <handler name="onvisible" >
> >>                this.adjustDimensions();
> >>            </handler>
> >>            <method name="adjustDimensions" >
> >>               this.setAttribute('width', classroot.width + 20);
> >>               var tw = Math.min(this.getTextWidth(),width);
> >>               var tx = (classroot.width - tw)/2;
> >>               this.setAttribute('x', tx);
> >>             </method>
> >>             <method name="makeVisible">
> >>
> >>             </method>
> >>        </text>
> >>
> >>
> >
> >
> > --
> > Henry Minsky
> > Software Architect
> > [email protected]
>
>


-- 
Henry Minsky
Software Architect
[email protected]

Reply via email to