Revision: 2017
          http://vexi.svn.sourceforge.net/vexi/?rev=2017&view=rev
Author:   clrg
Date:     2007-08-06 06:50:45 -0700 (Mon, 06 Aug 2007)

Log Message:
-----------
Fix up focus model with new event handling

Modified Paths:
--------------
    widgets/trunk/org.vexi.widgets/src/org/vexi/lib/role/focusmanager.t
    widgets/trunk/org.vexi.widgets/src/org/vexi/lib/role/surface.t

Modified: widgets/trunk/org.vexi.widgets/src/org/vexi/lib/role/focusmanager.t
===================================================================
--- widgets/trunk/org.vexi.widgets/src/org/vexi/lib/role/focusmanager.t 
2007-07-31 15:23:09 UTC (rev 2016)
+++ widgets/trunk/org.vexi.widgets/src/org/vexi/lib/role/focusmanager.t 
2007-08-06 13:50:45 UTC (rev 2017)
@@ -17,8 +17,8 @@
     
     <ui:box>
         
-        var focus = null;   // the current focus for this surface
-        var steallist = []; // list of boxes stealing keypress
+        // the current focus for this surface
+        var focus = null;
         
         // the focus list for this surface
         var fvector = vexi..vexi.util.vector..newVector();
@@ -121,48 +121,29 @@
             return v.focusable ? v : null;
         }
         
-        /** allow boxes to steal the keypress away from the focused widget */
-        surface.stealKeyEvents = function(v)
+        
+        //////// Key Event Handling ///////////////////////////////////
+        
+        /** pass key-press events to focused child */
+        var surfaceKeyPress = function(v)
         {
-            // prevent duplicate entries
-            surface.unstealKeyEvents(v);
-            // FIXME: need to fix unstealKeyEvents before doing the following
-            //steallist[steallist.length] = v;
-            steallist[0] = v;
+            surface.focusModelKeyPressed(v);
+            return;
         }
-
-        /** return focus model to normal operation after keypress stealing */
-        surface.unstealKeyEvents = function(v)
-        {
-            /* FIXME: concat does not seem to exist !?!?
-            for (var i=0; steallist.length>i; i++)
-            {
-                if (steallist[i] == v)
-                {
-                    steallist = [].concat(steallist.splice(0, i), 
steallist.splice(i+1, steallist.length));
-                    break;
-                }
-            }**/
-            // hack in lieu of the above problem
-            if (steallist[0] == v) steallist[0] = null;
-        }
         
-        /** pass key-press events to focused child */
-        surface._KeyPressed ++= function(v)
+        surface._KeyPressed ++= surfaceKeyPress;
+        
+        /** pass key-release events to focused child */
+        var surfaceKeyRelease = function(v)
         {
-            // boxes registered to steal keypress from focus model
-            //if (steallist.length > 0)
-            if (steallist[0])
-                steallist[steallist.length-1].KeyPressed = v;
-            // send event into focus model
-            else surface.focusModelKeyPress(v);
-            
-            // do not pass KeyPress event to box under mouse
-            return true;
+            surface.focusModelKeyReleased(v);
+            return;
         }
         
+        surface._KeyReleased ++= surfaceKeyRelease;
+        
         /** focus model keypress event */
-        surface.focusModelKeyPress = function(v)
+        surface.focusModelKeyPressed = function(v)
         {
             // if the focused widget wishes to intercept special keys
             if (focus and focus.grabKeyList and focus.grabKeyList[v])
@@ -203,23 +184,9 @@
             // pass keypress onto focused widget
             else if (focus) focus.KeyPressed = v;
         }
-        
-        /** pass key-release events to focused child */
-        surface._KeyReleased ++= function(v)
-        {
-            // boxes registered to steal keyrelease from focus model
-            //if (steallist.length > 0)
-            if (steallist[0])
-                steallist[steallist.length-1].KeyReleased = v;
-            // send event into focus model
-            else surface.focusModelKeyRelease(v);
 
-            // do not pass KeyRelease event to box under mouse
-            return true;
-        }
-
         /** focus model keyrelease event */
-        surface.focusModelKeyRelease = function(v)
+        surface.focusModelKeyReleased = function(v)
         {
             if (focus and ((focus.grabKeyList and focus.grabKeyList[v])
                 or v!="tab" or v!="TAB" or v.charCodeAt(0)!=65535))

Modified: widgets/trunk/org.vexi.widgets/src/org/vexi/lib/role/surface.t
===================================================================
--- widgets/trunk/org.vexi.widgets/src/org/vexi/lib/role/surface.t      
2007-07-31 15:23:09 UTC (rev 2016)
+++ widgets/trunk/org.vexi.widgets/src/org/vexi/lib/role/surface.t      
2007-08-06 13:50:45 UTC (rev 2017)
@@ -1,6 +1,7 @@
 <!-- Copyright 2006 - see COPYING for details [LGPL] -->
 
-<vexi xmlns:ui="vexi://ui" xmlns:meta="vexi://meta" 
xmlns:role="org.vexi.lib.role">
+<vexi xmlns:ui="vexi://ui" xmlns:meta="vexi://meta"
+    xmlns:role="org.vexi.lib.role" xmlns:rdrt="vexi.util.redirect">
     <meta:doc>
         <author>Charles Goodwin</author>
         <desc>Applied to every new surface (frame/window)</desc>
@@ -47,20 +48,21 @@
         s.delMoveTrap = function(v) { thisbox._Move --= v; }
         
         /** redirect events to the surface object for access */
-        vexi..vexi.util.redirect..addRedirect(surface, thisbox,
+        rdrt..addRedirect(surface, thisbox,
             "width", "height", "x", "y", "titlebar",
             "Focused", "Maximized", "Minimized",
             "Click1", "Click2", "Click3", "HScroll", "VScroll",
             "DoubleClick1", "DoubleClick2", "DoubleClick3",
-            "KeyPressed", "KeyReleased",
             "Press1", "Press2", "Press3",
             "Release1", "Release2", "Release3",
             "_Click1", "_Click2", "_Click3", "_HScroll", "_VScroll",
             "_DoubleClick1", "_DoubleClick2", "_DoubleClick3",
-            "_KeyPressed", "_KeyReleased",
             "_Press1", "_Press2", "_Press3",
             "_Release1", "_Release2", "_Release3" );
         
+        /** special case key events for focusable integration */
+        rdrt..addRedirect(thisbox, surface, "_KeyPressed", "_KeyReleased" );
+        
     </ui:box>
     <role:focusmanager />
     <role:popupmanager />


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: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Vexi-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to