Revision: 3458 http://vexi.svn.sourceforge.net/vexi/?rev=3458&view=rev Author: clrg Date: 2009-03-27 02:19:23 +0000 (Fri, 27 Mar 2009)
Log Message: ----------- Fix combo + add test Modified Paths: -------------- trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/option.t Added Paths: ----------- trunk/widgets/org.vexi.widgets/src_vunit/test/widget/combo.t 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-03-27 01:54:14 UTC (rev 3457) +++ trunk/widgets/org.vexi.widgets/src/org/vexi/lib/widget/option.t 2009-03-27 02:19:23 UTC (rev 3458) @@ -127,9 +127,11 @@ /** set display text on value write */ static.valueWrite = function(v) { var t = trapee; + var oldv = t.value; var s = t.v_listgroup ? t.v_listgroup.selected : null; - if (t.value != v and !t.popped) { - cascade = v; + cascade = v; + // search for value matches in children + if (oldv != v and !t.popped) { if (v==null) { if (s and s.selected) s.selected = false; } else { @@ -142,7 +144,10 @@ } } } - } else cascade = v; + } + // value has not changed but missing selected + if (!s and oldv == v) return; + // assign appropriate text content t.text = t.showvalue ? t.value : s ? s.text : ""; } Added: trunk/widgets/org.vexi.widgets/src_vunit/test/widget/combo.t =================================================================== --- trunk/widgets/org.vexi.widgets/src_vunit/test/widget/combo.t (rev 0) +++ trunk/widgets/org.vexi.widgets/src_vunit/test/widget/combo.t 2009-03-27 02:19:23 UTC (rev 3458) @@ -0,0 +1,64 @@ +<vexi xmlns:meta="vexi://meta" xmlns:ui="vexi://ui" xmlns="vexi.widget"> + <meta:doc> + <author>Charles Goodwin</author> + </meta:doc> + + <surface> + + var vunit = vexi..vexi.test.vunit; + var assertEq = vunit..assertEq; + var assertExceptionThrown = vunit..assertExceptionThrown; + + var b = .combo(vexi.box); + var i1 = .item(vexi.box); i1.text="An A"; i1.value="A"; + var i2 = .item(vexi.box); i2.text="B"; + b[0] = i1; i1.forcereflow(); + b[0] = i2; i2.forcereflow(); + + assertEq("",b.text); + assertEq(null,b.value); + // assign value + b.value = "A"; + assertEq("An A",b.text); + assertEq("A",b.value); + // repeat assign + b.value = "A"; + assertEq("An A",b.text); + assertEq("A",b.value); + // assign different + b.value = "B"; + assertEq("B",b.text); + assertEq("B",b.value); + /* FIXME: behaviour undefined/unimplemented + // assign missing + b.value = "C"; + /assertEq("C",b.text); + assertEq("C",b.value); + */ + + // simulate mouse interaction + b.focused = true; + b.popup = true; + i1.sendEvent("Move",1,1); // set MOUSEINSIDE + // value not yet assigned + assertEq("B",b.text); + assertEq("B",b.value); + // select with mouse value + i1.action = true; + b.popdown = true; + b.focused = false; + i1.sendEvent("Move",-1,-1); // set !MOUSEINSIDE + assertEq("An A",b.text); + assertEq("A",b.value); + /* FIXME: failing to replicate user interaction + // select with mouse+tab + b.popup = true; + i2.sendEvent("Move",1,1); // set MOUSEINSIDE + b.focused = false; + b.popdown = true; + assertEq("B",b.text); + assertEq("B",b.value); + */ + + </surface> +</vexi> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ _______________________________________________ Vexi-svn mailing list Vexi-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/vexi-svn