New abstract.redirectable

Charles Goodwin <[email protected]> Thu, 02 Oct 2003 11:24:59 +0100
Newsgroups gmane.comp.java.xwt.widgets
Organization XWT Foundation
Message-ID <[email protected]>
I'm beginning to really like all the changes in Nitrogen.  It just 
"Makes Sense" (TM).  How sweet is this:

<!-- Copyright 2003 Charles Goodwin
      LGPL - see COPYING for details -->

<xwt>
     <template>

         var redirectlist = {};

         addredirect += function( v ) {
             for ( p in v ) {
                 // remove the trap if it already exists
                 if ( redirectlist[p] ) thisbox[p] -= redirectlist[p];

                 // add new redirect trap, old trap cleaned up by xwt gc
                 redirectlist[p] = function( w ) { v[p][p] = w; return; }
                 thisbox[p] += redirectlist[p];
             }
         }

         delredirect += function( v ) {
             for ( p in v ) {
                 // remove trap and trap reference if it exists
                 if ( redirectlist[p] ) {
                     thisbox[p] -= redirectlist[p];
                     redirectlist[p] = null;
                 }
             }
         }

     </template>
</xwt>