Revision: 3963
          http://vexi.svn.sourceforge.net/vexi/?rev=3963&view=rev
Author:   clrg
Date:     2010-11-29 15:39:38 +0000 (Mon, 29 Nov 2010)

Log Message:
-----------
Tidy up only

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

Modified: trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/widget/menu.t
===================================================================
--- trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/widget/menu.t     
2010-11-10 20:30:29 UTC (rev 3962)
+++ trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/widget/menu.t     
2010-11-29 15:39:38 UTC (rev 3963)
@@ -23,18 +23,23 @@
             v_content.orient = "vertical";
             v_content.Children ++= function(c) {
                 if (c != null) {
-                    // for separators
-                    if (c.v_separator) c.vshrink = true;
-                    // add to existing itemgroup
-                    else if (v_itemgroup) {
+                    if (c.v_separator) {
+                        // for separators
+                        c.vshrink = true;
+                    } else if (v_itemgroup) {
+                        // add to existing itemgroup
                         c.group = v_itemgroup;
                         v_content.Leave ++= function(l) {
                             var s = v_itemgroup.selected;
-                            if (s and !s.popped) s.selected = false;
+                            if (s and !s.popped) {
+                                s.selected = false;
+                            }
                             cascade = l;
                         }
-                    // acquire starting itemgroup
-                    } else v_itemgroup = c.group;
+                    } else {
+                        // acquire starting itemgroup
+                        v_itemgroup = c.group;
+                    }
                     c.action ++= childActionWrite;
                 } else {
                     var _c = v_content[trapname];
@@ -49,7 +54,7 @@
         
         // assign static trap functions
         thisbox.popdown     ++= static.popdownWrite;
-        thisbox.popup       ++= static.popupWrite;
+        //thisbox.popup       ++= static.popupWrite;
         thisbox.selected    ++= static.selectedWrite;
         thisbox.Enter       ++= static.enterWrite;
         thisbox.Leave       ++= static.leaveWrite;
@@ -62,14 +67,18 @@
     /** become active menu on Enter */
     static.enterWrite = function(v) {
         var t = trapee;
-        if (t.enabled and !t.selected) t.selected = true;
+        if (t.enabled and !t.selected) {
+            t.selected = true;
+        }
         cascade = v;
     }
     
     /** become inactive on leave if menu is not open */
     static.leaveWrite = function(v) {
         var t = trapee;
-        if (!t.popped) t.selected = false;
+        if (!t.popped) {
+            t.selected = false;
+        }
         cascade = v;
     }
     
@@ -77,21 +86,36 @@
     static.keypressWrite = function(v) {
         var t = trapee;
         var g = t.v_itemgroup;
-        var s = g.selected;
-        // close down menu
-        if (v=="escape") trapee.popdown = true;
-        // move menu left if appropriate
-        else if (v=="left") {
-            if (g and s and s.popped) s.KeyPressed = v;
-            else if (trapee.prevselect) t.prevselect.selected = true;
-        // move to next menu to the right, if appropriate
-        } else if (v=="right") {
-            if (g and s and s.popupable) s.KeyPressed = v;
-            else if (t.nextselect) t.nextselect.selected = true;
-        // pass keypress onto selected menu entry or select a menu entry if 
none is selected
-        } else if (g) {
-            if (s) s.KeyPressed = v;
-            else if (g.first and (v=="up" or v=="down")) g.first.selected = 
true;
+        var s = g?.selected;
+        switch (v) {
+        case "escape":
+            // close down menu
+            trapee.popdown = true;
+            break;
+        case "left":
+            // move menu left if appropriate
+            if (g and s and s.popped) {
+                s.KeyPressed = v;
+            } else if (trapee.prevselect) {
+                t.prevselect.selected = true;
+            }
+            break;
+        case "right":
+            // move to next menu to the right, if appropriate
+            if (g and s and s.popupable) {
+                s.KeyPressed = v;
+            } else if (t.nextselect) {
+                t.nextselect.selected = true;
+            }
+            break;
+        default:
+            // pass keypress onto selected menu entry or select a menu entry 
if none is selected
+            if (s) {
+                s.KeyPressed = v;
+            } else if (g?.first and (v=="up" or v=="down")) {
+                g.first.selected = true;
+            }
+            break;
         }
         cascade = v;
     }
@@ -99,7 +123,9 @@
     /** pass key-release on as well */
     static.keyreleaseWrite = function(v) {
         var g = trapee.v_itemgroup;
-        if (g and g.selected) g.selected.KeyReleased = v;
+        if (g and g.selected) {
+            g.selected.KeyReleased = v;
+        }
         cascade = v;
     }
     
@@ -107,8 +133,11 @@
     static.pressWrite = function(v) {
         var t = trapee;
         if (t.enabled) {
-            if (t.popped) t.popdown = true;
-            else t.popup = true;
+            if (t.popped) {
+                t.popdown = true;
+            } else {
+                t.popup = true;
+            }
         }
         cascade = v;
     }
@@ -122,7 +151,9 @@
     /** popdown submenus as well */
     static.popdownWrite = function(v) {
         var g = trapee.v_itemgroup;
-        if (g and g.selected) g.selected.selected = false;
+        if (g and g.selected) {
+            g.selected.selected = false;
+        }
         // FIXME: surface._KeyPressed --=
         cascade = v;
     }
@@ -133,13 +164,13 @@
         var t = trapee;
         var g = t.group;
         if (v) {
-            if (g and g.selected and g.selected.popped)
+            if (g and g.selected and g.selected.popped) {
                 t.popup = true;
-        } else t.popdown = true;        
+            }
+        } else {
+            t.popdown = true;
+        }        
         cascade = v;
     }
     
-    /** prevent Press events from reaching surface */
-    static.popboxPressWrite = function(v) { return true; }
-    
 </vexi>

Modified: trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/widget/submenu.t
===================================================================
--- trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/widget/submenu.t  
2010-11-10 20:30:29 UTC (rev 3962)
+++ trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/widget/submenu.t  
2010-11-29 15:39:38 UTC (rev 3963)
@@ -12,7 +12,7 @@
         
         thisbox.action;
         thisbox.enabled = true;
-        thisbox.mnemoic;
+        thisbox.mnemonic;
         thisbox.selected = false;
         thisbox.v_itemgroup = null;
         thisbox.v_level = 1;
@@ -69,7 +69,7 @@
     static.v_levelWrite = function(v) {
         var t = trapee;
         var n = t.numchildren;
-        t.v_popbox.popgroup = "subv_level" + v;
+        t.v_popbox.popgroup = "submenu_level" + v;
         for (var i=0; n>i; i++) {
             t[i].v_level = v+1;
         }
@@ -80,27 +80,33 @@
     static.keypressWrite = function(v) {
         var t = trapee;
         var g = g;
-        if (v=="up" or v=="down") {
+        if (!g or !g.selected) {
             cascade = v;
-        } else if (g and g.selected) {
-            if (v == "left") {
-                if (g.selected.popped) {
-                    g.selected.KeyPressed = v;
-                } else {
-                    t.popdown = true;
-                }
-            } else if (v == "right") {
-                if (!t.popped) {
-                    t.popup = true;
-                } else {
-                    g.selected.KeyPressed = v;
-                }
+            return;
+        }
+        switch(v) {
+        case "up":
+        case "down":
+            cascade = v;
+            break;
+        case "left":
+            if (g.selected.popped) {
+                g.selected.KeyPressed = v;
             } else {
+                t.popdown = true;
+            }
+            break;
+        case "right":
+            if (!t.popped) {
+                t.popup = true;
+            } else {
                 g.selected.KeyPressed = v;
             }
-            return;
+            break;
+        case "default":
+            g.selected.KeyPressed = v;
+            break;
         }
-        cascade = v;
     }
     
     /** deselect selected submenu item on popdown */
@@ -132,7 +138,6 @@
     static.popboxWrite = function(v) {
         cascade = v;
         v.popgroup = "sublevel" + trapee.v_level;
-        v.Press1 ++= .menu..popboxPressWrite;
     }
     
 </vexi>


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

------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
Vexi-svn mailing list
Vexi-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to