|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
setText method on LzText class 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> Henry Minsky Software Architect hminsky@... |
|
|
Re: setText method on LzText classActually, 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@...> wrote:
-- Henry Minsky Software Architect hminsky@... |
|
|
|
|
|
Re: setText method on LzText classI like this solution better than the magic/optional force flag.
The whole bit about overriding setters boils down to fixing http://jira.openlaszlo.org/jira/browse/LPP-5587 which is next on my list. On 2008-07-23, at 04:30EDT, André Bargull wrote: > 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@...> 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> > |
| Free Forum Powered by Nabble | Forum Help |