Revision: 2411
          http://vexi.svn.sourceforge.net/vexi/?rev=2411&view=rev
Author:   clrg
Date:     2007-10-02 18:34:43 -0700 (Tue, 02 Oct 2007)

Log Message:
-----------
Use the Children trap properly in menu implementations

Modified Paths:
--------------
    trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/menu.t
    trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/submenu.t

Modified: trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/menu.t
===================================================================
--- trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/menu.t       
2007-10-02 14:16:46 UTC (rev 2410)
+++ trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/menu.t       
2007-10-03 01:34:43 UTC (rev 2411)
@@ -14,49 +14,40 @@
         thisbox.th_content;
         thisbox.th_list;
         
-        var lockChildren = false;
-        
         /** th_content write trap */
         thisbox.th_content ++= function(v) {
+            cascade = v;
             v.Children ++= function(c) {
                 // for separators
-                if (c.v_is_separator)
-                    c.vshrink = true;
-                // if locked, spoof put from th_list is in action
-                if (lockChildren) return;
-                // otherwise redirect child put to th_list
-                lockChildren = true;
+                if (c and c.v_is_separator) c.vshrink = true;
+                // redirect to th_list
                 th_list[th_list.numchildren] = c;
-                lockChildren = false;
-                // never complete the put
                 return;
             }
-            
             v.Children ++= function() { return th_list[trapname]; }
-            
-            cascade = v;
+            v.numchildren ++= function() { return th_list.numchildren; }
         }
-
+        
         /** popdown menu when a menu item is fired */
         var childActionWrite = function(v) { popdown = true; cascade = v; }
         
         /** th_list write trap */
         thisbox.th_list ++= function(v) {
+            cascade = v;
             v.Children ++= function(c) {
+                if (c != null) {
+                    if (itemgroup) c.group = itemgroup;
+                    else itemgroup = c.group;
+                    c.action ++= childActionWrite;
+                } else {
+                    var _c = v[trapname];
+                    if (_c) {
+                        c.action --= childActionWrite;
+                        c.group = null;
+                    }
+                }
                 cascade = c;
-                if (c == null) return;
-                if (itemgroup) c.group = itemgroup;
-                else itemgroup = c.group;
-                c.action ++= childActionWrite;
-                // if locked, put has been redirected here from th_content
-                if (lockChildren) return;
-                // otherwise spoof the put back to th_content
-                lockChildren = true;
-                th_content[trapname] = c;
-                lockChildren = false;
             }
-            
-            cascade = v;
         }
         
         // assign static trap functions

Modified: trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/submenu.t
===================================================================
--- trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/submenu.t    
2007-10-02 14:16:46 UTC (rev 2410)
+++ trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/submenu.t    
2007-10-03 01:34:43 UTC (rev 2411)
@@ -17,53 +17,41 @@
         thisbox.th_content = null;
         thisbox.th_list = null;
         
-        var lockChildren = false;
-        
         /** th_content write trap */
         thisbox.th_content ++= function(v) {
+            cascade = v;
             v.Children ++= function(c) {
                 // for separators
-                if (c.v_is_separator)
-                    c.vshrink = true;
-                // if locked, spoof put from th_list is in action
-                if (lockChildren) return;
-                // otherwise redirect child put to th_list
-                lockChildren = true;
+                if (c and c.v_is_separator) c.vshrink = true;
+                // redirect to th_list
                 th_list[th_list.numchildren] = c;
-                lockChildren = false;
-                // never complete the put
                 return;
             }
-            
             v.Children ++= function() { return th_list[trapname]; }
-            
-            cascade = v;
+            v.numchildren ++= function() { return th_list.numchildren; }
         }
         
         /** popdown menu when a menu item is fired */
-        var childActionWrite = function(v) { cascade = v; popdown = true; }
+        var childActionWrite = function(v) { popdown = true; cascade = v; }
         
-        /** set up submenu item list */
+        /** th_list write trap */
         thisbox.th_list ++= function(v) {
+            cascade = v;
             v.Children ++= function(c) {
-                if (c == null) {
-                    // FIXME: deal with removal of children
-                } else {
+                if (c != null) {
                     if (itemgroup) c.group = itemgroup;
                     else itemgroup = c.group;
-                    c.level = level+1;
                     c.action ++= childActionWrite;
-                    // if locked, put has been redirected here from th_content
-                    if (lockChildren) { cascade = c; return; }
-                    // otherwise spoof the put back to th_content
-                    lockChildren = true;
-                    th_content[trapname] = c;
-                    lockChildren = false;
+                    c.level = level+1;
+                } else {
+                    var _c = v[trapname];
+                    if (_c) {
+                        c.action --= childActionWrite;
+                        c.group = null;
+                    }
                 }
                 cascade = c;
             }
-            
-            cascade = v;
         }
         
         // assign static trap functions
@@ -110,8 +98,7 @@
     }
     
     /** deselect selected submenu item on popdown */
-    static.popdownWrite = function(v)
-    {
+    static.popdownWrite = function(v) {
         cascade = v;
         var t = trapee;
         var g = g;
@@ -120,16 +107,14 @@
     }
     
     /** popup/down when selected/unselected */
-    static.selectWrite = function(v)
-    {
+    static.selectWrite = function(v) {
         cascade = v;
         if (v) trapee.popup = true;
         else trapee.popdown = true;
     }
     
     /** set up popbox */
-    static.popboxWrite = function(v)
-    {
+    static.popboxWrite = function(v) {
         cascade = v;
         v.popgroup = "sublevel" + trapee.level;
         v.Press1 ++= .menu..popboxPressWrite;


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Vexi-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to