Revision: 3757
          http://vexi.svn.sourceforge.net/vexi/?rev=3757&view=rev
Author:   clrg
Date:     2009-11-19 02:50:56 +0000 (Thu, 19 Nov 2009)

Log Message:
-----------
Fix some combo bugs

Modified Paths:
--------------
    trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/combo.t
    trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/option.t
    trunk/widgets/org.vexi.widgets/src/org/vexi/theme/classic/option.t

Modified: trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/combo.t
===================================================================
--- trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/combo.t      
2009-11-12 02:46:39 UTC (rev 3756)
+++ trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/combo.t      
2009-11-19 02:50:56 UTC (rev 3757)
@@ -5,8 +5,8 @@
         <author>Charles Goodwin</author>
     </meta:doc>
     
+    <text.field />
     <widget.option />
-    <text.field />
     <ui:box>
         
         // public vars
@@ -26,16 +26,26 @@
     /** special case keypresses for combo, falling back to option keypress 
when needed */
     static.keypressEvent = function(v) {
         var t = trapee;
-        if (v=="escape" or v=="up" or v=="down") {
+        switch (v) {
+        case "escape":
+        case "up":
+        case "down":
+            // defer to lib.option
             cascade = v;
-        } else if (v=="enter") {
+            break;
+        
+        case "enter":
             if (t.popped) {
+                // defer to lib.option
                 cascade = v;
             } else {
                 t.value = t.v_textbox.text;
             }
-        } else {
-            var s = t.v_listgroup ? t.v_listgroup.selected : null;
+            break;
+        
+        default:
+            var g = t.v_listgroup;
+            var s = g ? g.selected : null;
             if (s) {
                 s.selected = false;
             }
@@ -47,8 +57,8 @@
                     t.popup = true;
                 }
             }
+            break;
         }
-        return;
     }
     
     /** restore display if matchtext is disabled */
@@ -74,19 +84,21 @@
     static.popupWrite = function(v) {
         cascade = v;
         if (trapee.matchtext) {
-            static.match(trapee.v_edit.text, trapee);
+            static.match(trapee.v_edit.text, trapee.v_listgroup);
         }
     }
     
     /** match/hide items on demand */
     static.match = function(text, list) {
+        if (list==null) {
+            return;
+        }
         // FIXME: this is inefficient, to say the least
+        var vec = list.members;
+        var item = vec.first;
         var match = text.toLowerCase();
-        var len = match.length;
-        var n = list.numchildren;
         var f = true;
-        for (var i=0; n>i; i++) {
-            var item = list[i];
+        while (item!=null) {
             if (!item.ignorematch) {
                 item.display = (item.text.toLowerCase().indexOf(match) >= 0);
                 if (f and item.display) {
@@ -94,18 +106,26 @@
                     f = false;
                 }
             }
+            item = vec.after(item);
         }
     }
     
     /** restore the combo list */
     static.unmatch = function(list) {
-        var n = list.numchildren;
-        for (var i=0; n>i; i++) {
-            var item = list[i];
-            item.selected = false;
+        if (list==null) {
+            return;
+        }
+        var vec = list.members;
+        var item = vec.first;
+        while (item!=null) {
             if (!item.ignorematch) {
                 item.display = true;
             }
+            if (item.selected) {
+                item.selected = false;
+                break;
+            }
+            item = vec.after(item);
         }
     }
     

Modified: trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/option.t
===================================================================
--- trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/option.t     
2009-11-12 02:46:39 UTC (rev 3756)
+++ trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/option.t     
2009-11-19 02:50:56 UTC (rev 3757)
@@ -152,8 +152,8 @@
         var g = t.v_listgroup;
         var s = g ? g.selected : null;
         cascade = v;
-        // search for value matches in children
         if (oldv != v) {
+            // search for value matches in children
             if (v==null) {
                 if (s and s.selected) {
                     s.selected = false;
@@ -170,8 +170,8 @@
                 }
             }
         }
-        // value has not changed but missing selected
         if (!s and oldv == v) {
+            // value has not changed but missing selected
             return;
         }
         // assign appropriate text content
@@ -182,14 +182,9 @@
     static.keypressEvent = function(v) {
         var t = trapee;
         var s = t.v_listgroup ? t.v_listgroup.selected : null;
-        if (v == ' ') {
-            // open/close on space
-            if (t.popped) {
-                t.popdown = true;
-            } else {
-                t.popup = true;
-            }
-        } else if (v == "down") {
+        
+        switch (v) {
+        case "down":
             // select next item on arrow down
             if (t.popped) {
                 // if open select the next one
@@ -205,7 +200,9 @@
                 // popup if not already popped
                 t.popup = true;
             }
-        } else if (v == "up") {
+            break;
+        
+        case "up":
             // behaviour for up arrow
             if (t.popped) {
                 // select previous item
@@ -221,14 +218,18 @@
                 // popup if not already popped
                 t.popup = true;
             }
-        } else if (v == "enter") {
+            break;
+        
+        case "enter":
             // close positively on enter
             if (t.popped) {
                 t.popdown = true;
             } else {
                 t.action = true;
             }
-        } else if (v == "escape") {
+            break;
+        
+        case "escape":
             // keep original value
             if (t.popped) {
                 if (s) {
@@ -236,11 +237,14 @@
                 }
                 t.popdown = true;
             }
-        } else if (v == "back_space") {
+            break;
+        
+        case "back_space":
             // clear value altogether
             t.popdown = true;
             t.value = null;
             t.text = "";
+            break;
         }
         cascade = v;
     }

Modified: trunk/widgets/org.vexi.widgets/src/org/vexi/theme/classic/option.t
===================================================================
--- trunk/widgets/org.vexi.widgets/src/org/vexi/theme/classic/option.t  
2009-11-12 02:46:39 UTC (rev 3756)
+++ trunk/widgets/org.vexi.widgets/src/org/vexi/theme/classic/option.t  
2009-11-19 02:50:56 UTC (rev 3757)
@@ -59,11 +59,13 @@
         $focus.minheight = 6 + vexi.ui.font.height(font, fontsize, "dy");
         
         thisbox.surfaceWidth = function(dx, sw) {
+            vexi.trace(v_popbox.width);
             v_popbox.surface_x =
                 vexi.math.min(dx+marginleft+1, vexi.math.max(0, 
sw-v_popbox.width));
         }
         
         thisbox.surfaceHeight = function(dy, sh) {
+            vexi.trace(v_popbox.height);
             v_popbox.surface_y =
                 vexi.math.min(dy+height-marginbottom-2, sh-v_popbox.height);
         }


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

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Vexi-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to