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

Jeff Buhrt <[email protected]> Sat, 13 Dec 2003 15:59:08 -0500
Newsgroups gmane.comp.java.xwt.users
Message-ID <[email protected]>
Charlie,

Thanks. I figured out how to do the template part.
Don't apply the template to the 'prototype' boxes but just put it in a 
property (applyThis="textfield", etc.)
    -now I can apply the the template to the box.

Noting Nitrogen does implement cloning I will make sure to wrap my 
method, clone sounds like a good name ;)

Thanks again Charlie,

-Jeff

Charles Goodwin wrote:

>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
>
>  
>