Revision: 4340
          http://vexi.svn.sourceforge.net/vexi/?rev=4340&view=rev
Author:   clrg
Date:     2012-01-25 14:44:19 +0000 (Wed, 25 Jan 2012)
Log Message:
-----------
Subtle change to focus behaviour - defocus previous focusable before focus 
assignment (was after)

Modified Paths:
--------------
    trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/role/focusable.t
    trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/role/focusmanager.t

Modified: trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/role/focusable.t
===================================================================
--- trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/role/focusable.t  
2012-01-25 14:42:26 UTC (rev 4339)
+++ trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/role/focusable.t  
2012-01-25 14:44:19 UTC (rev 4340)
@@ -114,13 +114,13 @@
     
     /** write trap to handle surface change */
     static.surfaceWrite = function(v) {
-        // drop from current surface
         var s = trapee.surface;
         if (s and s.focus) {
+            // drop from current surface
             s.focus.dropFocus(trapee);
         }
-        // add to new surface
         if (v and v.focus) {
+            // add to new surface
             v.focus.addFocus(trapee);
         }
         cascade = v;

Modified: trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/role/focusmanager.t
===================================================================
--- trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/role/focusmanager.t       
2012-01-25 14:42:26 UTC (rev 4339)
+++ trunk/org.vexi-vexi.widgets/src_main/org/vexi/lib/role/focusmanager.t       
2012-01-25 14:44:19 UTC (rev 4340)
@@ -57,24 +57,32 @@
             }
         }
         
+        var defocus;
+        
         /** set or unset a focused widget */
         model.setFocus = function(v, f) {
             if (f and fvector.contains(v)) {
+                // valid request to focus
                 if (focus != v) {
-                    var defocus = focus;
+                    defocus = focus;
+                    if (defocus) {
+                        try { defocus.focused = false; }
+                        finally { defocus = null; }
+                    }
                     // focus
                     focus = v;
                     model.current = v;
-                    // REMARK: we handle defocusing after setting
-                    // the focus to avoid entering setFocus twice
-                    if (defocus) {
-                        defocus.focused = false;
-                    }
                 }
                 return true;
             } else if (!f and focus == v) {
-                // defocus
+                // request to unfocus
+                if (defocus == v) {
+                    // already in setFocus; defocus as
+                    // part of focusing another widget
+                    return false;
+                }
                 if (surfaceFocused) {
+                    // defocus
                     focus = null;
                     model.current = null;
                     return false;

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


------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
Vexi-svn mailing list
Vexi-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to