Revision: 2802
          http://vexi.svn.sourceforge.net/vexi/?rev=2802&view=rev
Author:   clrg
Date:     2008-02-25 19:17:34 -0800 (Mon, 25 Feb 2008)

Log Message:
-----------
Major clean up & fixes to broken value/selection logic in list/option

Modified Paths:
--------------
    trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/list.t
    trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/option.t

Modified: trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/list.t
===================================================================
--- trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/list.t       
2008-02-26 01:14:23 UTC (rev 2801)
+++ trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/list.t       
2008-02-26 03:17:34 UTC (rev 2802)
@@ -13,6 +13,7 @@
         
         // private variables
         var listgroup;
+        var valueset = false;
         var values = {};
         
         /** return the currently selected item */
@@ -25,11 +26,28 @@
         
         /** select item corresponding to value v */
         value ++= function(v) {
-            if (v and values[v]) values[v].selected = true;
-            else if (listgroup and listgroup.selected) 
listgroup.selected.selected = false;
+            if (!valueset) {
+                valueset = true;
+                // select value
+                if (v and values[v]) values[v].selected = true;
+                // deselect current value
+                else if (listgroup and listgroup.selected)
+                    listgroup.selected.selected = false;
+                valueset = false;
+            }
             return;
         }
         
+        var listSelectWrite = function(v) {
+            cascade = v;
+            selected = v;
+            if (!valueset) {
+                valueset = true;
+                value = v ? v.value : null;
+                valueset = false;
+            }
+        }
+        
         /** updates the value reference */
         var itemValueWrite = function(v) {
             var wasnull = false;
@@ -61,13 +79,13 @@
                     if (listgroup) c.group = listgroup;
                     else {
                         listgroup = c.group;
-                        listgroup.selected ++= function(v) { cascade = v; 
value = v ? v.value : null; }
+                        listgroup.selected ++= listSelectWrite;
                     }
                     // lookup for c by value
                     if (values[c.value]) throw "can not have duplicate values 
in a list";
                     values[c.value] = c;
                     // respect selected state of c
-                    if (c.selected) value = c.value;
+                    if (c.selected) selected = c;
                 } else {
                     var _c = v[trapname];
                     if (_c) {

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     
2008-02-26 01:14:23 UTC (rev 2801)
+++ trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/option.t     
2008-02-26 03:17:34 UTC (rev 2802)
@@ -73,13 +73,21 @@
         v.p_option = trapee;
         v.Children ++= static.contentChildrenWrite;
         v.Release1 ++= static.contentReleaseEvent;
-        v.value ++= static.contentValueWrite;
+        v.selected ++= static.contentSelectWrite;
     }
     
     /** forward content value updates to option */
-    static.contentValueWrite = function(v) {
-        cascade = v;
-        if (!trapee.p_option.popped) trapee.p_option.value = v;
+    //static.contentValueWrite = function(v) {
+    //    cascade = v;
+        //if (!trapee.p_option.popped) trapee.p_option.value = v;
+    //}
+    
+    /** forward content value updates to option */
+    static.contentSelectWrite = function(s) {
+        cascade = s;
+        var o = trapee.p_option;
+        if (!o.popped)
+            o.th_output.text = s ? (o.showvalue ? s.value : s.text) : "";
     }
     
     /** disabled option must be popped down */
@@ -91,9 +99,10 @@
     
     /** popdown post-selection of item */
     static.popdownWrite = function(v) {
+        cascade = v;
         var t = trapee;
-        t.value = t.th_content.value;
-        cascade = v;
+        var s = t.th_content.selected;
+        t.th_output.text = s ? (t.showvalue ? s.value : s.text) : "";
     }
     
     /** popdown post-selection of item */
@@ -118,14 +127,7 @@
     
     /** appropriate assign value  - selection logic 
      *  is handled by selectable in th_content list */
-    static.valueWrite = function(v) {
-        var t = trapee;
-        var s = t.th_content.selected;
-        if (!t.popped and (s==null or s.value!=v))
-            t.th_content.selected = v;
-        t.th_output.text = s ? (t.showvalue ? s.value : s.text) : "";
-        return;
-    }
+    static.valueWrite = function(v) { trapee.th_content.value = v; return; }
     
     /** applied to list items */
     static.enterEvent = function(v) {


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 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Vexi-svn mailing list
Vexi-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to