Re: [xwt-users] Is there a way to clone a box?

Charles Goodwin <[email protected]> Sat, 13 Dec 2003 19:51:33 +0000
Newsgroups gmane.comp.java.xwt.users
Organization XWT Foundation - www.xwt.org
Message-ID <[email protected]>
On Sat, 2003-12-13 at 16:35, Jeff Buhrt wrote:
> Is there any way to java-like clone a box in Lithium?
> 
> I can manually copy the properties, but how do I make 'copy' be a box, 
> textfield, button?
>     [And/or how do I find the template that was applied?]

This was extensively discussed a while back.

What we agreed to do before the focus shifted onto Nitrogen was to have
boxes implement a __clone read trap that would return a copy of said
box:

__clone = function() {
    var ret = xwt.newBox().apply( "x.y.z" );
    for ( p in thisbox ) ret[p] = thisbox[p];
    return ret;
}

That's the best way to approach the situation in Lithium.  Nitrogen
implements automatic cloning.

As for finding the preapplies of a template, there is no possible way to
do that because it:
  1) would have severely compromised the speed of XWT
  2) can be done using the above technique
  3) is would allow 'dodgy' introspection of boxes and encourage
     poor software engineering techniques

- Charlie

-- 
Charles Goodwin <[email protected]>
XWT Foundation - www.xwt.org