[Laszlo-dev] setText method on LzText class

André Bargull a.bargull at intensis.de
Wed Jul 23 01:30:11 PDT 2008


Maybe we should just change the setText()-API and remove the internal 
argument "force".
> function setText ( t, *force = null*){

For instance by adding a private "__textdirty"-flag to LzText:
> var __textdirty :Boolean = false;
>
> function setText ( t ){
>     // force to a string
>     t = '' + t;
>     if (!this.__textdirty && t == this.getText()) return;
>     this.__textdirty = false;

Then we need to update setMaxLength(), setFontName() and setFontSize() 
to set "__textdirty" to true. (I didn't see any other callers which use 
the force-flag, I've searched in the LFC & components.)
Thoughts?

> Actually, I don't know if calling super.setAttribute is going to do 
> the right thing, maybe the mySetText method needs to call the super 
> setter explicitly? <text name="alerttext" x="${parent.text_x}" 
> y="${parent.text_y}" resize="true" multiline="true"> <attribute 
> name="text" type="text" value="${parent.text}" 
> setter="this.mySetText(text)"/> <method name="mySetText" args="t"> 
> .... super.$lzc$set_text(t); </method> On Tue, Jul 22, 2008 at 11:52 
> PM, Henry Minsky <hminsky at laszlosystems.com> wrote:
>> >  I came across this code in the alert component
>> >         <text name="alerttext" x="${parent.text_x}" y="${parent.text_y}"
>> >             resize="true" text="${parent.text}" multiline="true">
>> >             <method name="setText" args="t">
>> >                 super.setText(t);
>> >                  ....
>> >
>> >
>> > which gets a swf9 error about an incompatible override, and in fact that's
>> > true, LzText.setText is defined as
>> > having a second optional arg
>> >
>> > LzText.setText is actually deprecated, and it has the method signature
>> >
>> >      function setText ( t, force = null){
>> >
>> > So what is the right way for user code to override the text setter on
>> > LzText? It seems like for
>> > one thing you should not need to know about the magic second arg. I don't
>> > think we want people
>> > to have to do
>> >
>> > <method name="$lzc$set_text" args="v">
>> > either..
>> >
>> >
>> > Is the approved way to ask them to declare the setter as an attribute?
>> >
>> > <text>
>> >    <attribute name="text" setter="..."
>> >
>> > So for alert code shown above, we need to move that text=${parent.text}
>> > constraint to the attribute declaration, and it becomes
>> >
>> >         <text name="alerttext" x="${parent.text_x}" y="${parent.text_y}"
>> >             resize="true" multiline="true">
>> >             <attribute name="text" type="text" value="${parent.text}"
>> > setter="this.mySetText(text)"/>
>> >             <method name="mySetText" args="t">
>> >                 ....
>> >                 super.setAttribute('text',t);
>> >              </method>



More information about the Laszlo-dev mailing list