This is an automated email from the ASF dual-hosted git repository.

aharui pushed a commit to branch feature/MXRoyale
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git

commit be05e5ada3c2daf03c38ebbe37e50ee7df912417
Author: Alex Harui <[email protected]>
AuthorDate: Tue Apr 3 12:06:04 2018 -0700

    implement support for FocusManager
---
 .../src/main/royale/mx/core/Application.as         |   6 +-
 .../MXRoyale/src/main/royale/mx/core/Container.as  |   6 +-
 .../src/main/royale/mx/core/UIComponent.as         | 216 ++++++++++++++++++++-
 3 files changed, 214 insertions(+), 14 deletions(-)

diff --git 
a/frameworks/projects/MXRoyale/src/main/royale/mx/core/Application.as 
b/frameworks/projects/MXRoyale/src/main/royale/mx/core/Application.as
index ec97273..82db42e 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/core/Application.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/core/Application.as
@@ -41,7 +41,6 @@ import flash.utils.setInterval;
 import mx.containers.utilityClasses.ApplicationLayout;
 import mx.effects.EffectManager;
 import mx.events.FlexEvent;
-import mx.managers.FocusManager;
 import mx.managers.IActiveWindowManager;
 import mx.managers.ILayoutManager;
 import mx.managers.ISystemManager;
@@ -63,6 +62,7 @@ import flash.utils.getQualifiedClassName;
 import org.apache.royale.events.utils.MouseEventConverter;
 }
 
+import mx.managers.FocusManager;
 import mx.containers.beads.ApplicationLayout;
 import mx.containers.beads.BoxLayout;
 
@@ -494,7 +494,7 @@ public class Application extends Container implements 
IStrand, IParent, IEventDi
         */
        private function initManagers():void
        {
-               // install FocusManager
+               focusManager = new FocusManager(this);
        }
        
        /**
@@ -550,6 +550,8 @@ public class Application extends Container implements 
IStrand, IParent, IEventDi
         // because the parent is the browser, not an IUIBase, but we
         // need to run most of the code that usually runs when added.
         addBead(new MixinManager());
+        initManagers();
+        
                addedToParent();
                        
                dispatchEvent('initialize');
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/core/Container.as 
b/frameworks/projects/MXRoyale/src/main/royale/mx/core/Container.as
index 936cb9a..616926c 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/core/Container.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/core/Container.as
@@ -77,6 +77,7 @@ import mx.events.ChildExistenceChangedEvent;
 */
 import mx.events.FlexEvent;
 import mx.events.IndexChangedEvent;
+import mx.managers.IFocusManagerContainer;
 COMPILE::SWF
 {
 import flash.display.DisplayObject;
@@ -88,7 +89,6 @@ import mx.events.ScrollEventDetail;
 import mx.events.ScrollEventDirection;
 import mx.geom.RoundedRectangle;
 import mx.managers.IFocusManager;
-import mx.managers.IFocusManagerContainer;
 import mx.managers.ILayoutManagerClient;
 import mx.managers.ISystemManager;
 import mx.styles.CSSStyleDeclaration;
@@ -315,9 +315,9 @@ use namespace mx_internal;
 public class Container extends UIComponent
                                           implements IDataRenderer, IChildList,
                                           IContainer, ILayoutParent, 
ILayoutView, IContentViewHost,
-                                          IStrandPrivate, IMXMLDocument
+                                          IStrandPrivate, IMXMLDocument, 
IFocusManagerContainer
                        //implements IContainer, IDataRenderer,
-                       //IFocusManagerContainer, IListItemRenderer,
+                       //IListItemRenderer,
                        //IRawChildrenContainer, IChildList, 
IVisualElementContainer,
                        //INavigatorContent
 
diff --git 
a/frameworks/projects/MXRoyale/src/main/royale/mx/core/UIComponent.as 
b/frameworks/projects/MXRoyale/src/main/royale/mx/core/UIComponent.as
index 87886e8..4411d5b 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/core/UIComponent.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/core/UIComponent.as
@@ -41,24 +41,27 @@ import flash.events.EventPhase;
 import flash.events.FocusEvent;
 import flash.events.IEventDispatcher;
 */
+
 import mx.controls.beads.ToolTipBead;
 import mx.events.FlexEvent;
 import mx.managers.ICursorManager;
 import mx.managers.IFocusManager;
+import mx.managers.IFocusManagerContainer;
 import mx.managers.ISystemManager;
 
 import org.apache.royale.core.CallLaterBead;
 import org.apache.royale.core.IStatesImpl;
 import org.apache.royale.core.IStatesObject;
+import org.apache.royale.core.IUIBase;
 import org.apache.royale.core.TextLineMetrics;
 import org.apache.royale.core.UIBase;
 import org.apache.royale.core.ValuesManager;
-import org.apache.royale.html.supportClasses.ContainerContentArea;
 import org.apache.royale.events.Event;
 import org.apache.royale.events.KeyboardEvent;
 import org.apache.royale.events.ValueChangeEvent;
 import org.apache.royale.geom.Point;
 import org.apache.royale.geom.Rectangle;
+import org.apache.royale.html.supportClasses.ContainerContentArea;
 import org.apache.royale.utils.PointUtils;
 import org.apache.royale.utils.loadBeadFromValuesManager;
 
@@ -483,6 +486,187 @@ public class UIComponent extends UIBase
     }
 
     //----------------------------------
+    //  focusEnabled
+    //----------------------------------
+    
+    /**
+     *  @private
+     *  Storage for the focusEnabled property.
+     */
+    private var _focusEnabled:Boolean = true;
+    
+    [Inspectable(defaultValue="true")]
+    
+    /**
+     *  Indicates whether the component can receive focus when tabbed to.
+     *  You can set <code>focusEnabled</code> to <code>false</code>
+     *  when a UIComponent is used as a subcomponent of another component
+     *  so that the outer component becomes the focusable entity.
+     *  If this property is <code>false</code>, focus is transferred to
+     *  the first parent that has <code>focusEnable</code>
+     *  set to <code>true</code>.
+     *
+     *  <p>The default value is <code>true</code>, except for the 
+     *  spark.components.Scroller component. 
+     *  For that component, the default value is <code>false</code>.</p>
+     *
+     *  @see spark.components.Scroller
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public function get focusEnabled():Boolean
+    {
+        return _focusEnabled;
+    }
+    
+    /**
+     *  @private
+     */
+    public function set focusEnabled(value:Boolean):void
+    {
+        _focusEnabled =  value;
+    }
+    
+    //----------------------------------
+    //  hasFocusableChildren
+    //----------------------------------
+    
+    /**
+     *  @private
+     *  Storage for the hasFocusableChildren property.
+     */
+    private var _hasFocusableChildren:Boolean = false;
+    
+    [Bindable("hasFocusableChildrenChange")]
+    [Inspectable(defaultValue="false")]
+    
+    /**
+     *  A flag that indicates whether child objects can receive focus.
+     * 
+     *  <p><b>Note: </b>This property is similar to the 
<code>tabChildren</code> property
+     *  used by Flash Player. 
+     *  Use the <code>hasFocusableChildren</code> property with Flex 
applications.
+     *  Do not use the <code>tabChildren</code> property.</p>
+     * 
+     *  <p>This property is usually <code>false</code> because most components
+     *  either receive focus themselves or delegate focus to a single
+     *  internal sub-component and appear as if the component has
+     *  received focus. 
+     *  For example, a TextInput control contains a focusable
+     *  child RichEditableText control, but while the RichEditableText
+     *  sub-component actually receives focus, it appears as if the
+     *  TextInput has focus. TextInput sets <code>hasFocusableChildren</code>
+     *  to <code>false</code> because TextInput is considered the
+     *  component that has focus. Its internal structure is an
+     *  abstraction.</p>
+     *
+     *  <p>Usually only navigator components, such as TabNavigator and
+     *  Accordion, have this flag set to <code>true</code> because they
+     *  receive focus on Tab but focus goes to components in the child
+     *  containers on further Tabs.</p>
+     *
+     *  <p>The default value is <code>false</code>, except for the 
+     *  spark.components.Scroller component. 
+     *  For that component, the default value is <code>true</code>.</p>
+     *
+     *  @see spark.components.Scroller
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public function get hasFocusableChildren():Boolean
+    {
+        return _hasFocusableChildren;
+    }
+    
+    /**
+     *  @private
+     */
+    public function set hasFocusableChildren(value:Boolean):void
+    {
+        if (value != _hasFocusableChildren)
+        {
+            _hasFocusableChildren = value;
+            dispatchEvent(new Event("hasFocusableChildrenChange"));
+        }
+    }
+    
+    //----------------------------------
+    //  tabFocusEnabled
+    //----------------------------------
+    
+    /**
+     *  @private
+     *  Storage for the tabFocusEnabled property.
+     */
+    private var _tabFocusEnabled:Boolean = true;
+    
+    [Bindable("tabFocusEnabledChange")]
+    [Inspectable(defaultValue="true")]
+    
+    /**
+     *  A flag that indicates whether this object can receive focus
+     *  via the TAB key
+     * 
+     *  <p>This is similar to the <code>tabEnabled</code> property
+     *  used by the Flash Player.</p>
+     * 
+     *  <p>This is usually <code>true</code> for components that
+     *  handle keyboard input, but some components in controlbars
+     *  have them set to <code>false</code> because they should not steal
+     *  focus from another component like an editor.
+     *  </p>
+     *
+     *  @default true
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public function get tabFocusEnabled():Boolean
+    {
+        return _tabFocusEnabled;
+    }
+    
+    /**
+     *  @private
+     */
+    public function set tabFocusEnabled(value:Boolean):void
+    {
+        if (value != _tabFocusEnabled)
+        {
+            _tabFocusEnabled = value;
+            dispatchEvent(new Event("tabFocusEnabledChange"));
+        }
+    }
+    
+    //----------------------------------
+    //  tabIndex
+    //----------------------------------
+    
+
+    COMPILE::JS
+    public function get tabIndex():int
+    {
+        return element.tabIndex;
+    }
+    
+    /**
+     *  @private
+     */
+    COMPILE::JS
+    public function set tabIndex(value:int):void
+    {
+        element.tabIndex =  value;
+    }
+    
+    //----------------------------------
     //  cacheAsBitmap
     //----------------------------------
 
@@ -603,9 +787,19 @@ public class UIComponent extends UIBase
      */
     public function get focusManager():IFocusManager
     {
-        // TODO
-        if (GOOG::DEBUG)
-            trace("focusManager not implemented");
+        if (_focusManager)
+            return _focusManager;
+        
+        var o:IUIBase = parent as IUIBase;
+        
+        while (o)
+        {
+            if (o is IFocusManagerContainer)
+                return IFocusManagerContainer(o).focusManager;
+            
+            o = o.parent as IUIBase;
+        }
+        
         return null;
     }
 
@@ -615,9 +809,7 @@ public class UIComponent extends UIBase
      */
     public function set focusManager(value:IFocusManager):void
     {
-        // TODO
-        if (GOOG::DEBUG)
-            trace("focusManager not implemented");
+        _focusManager = value;
     }
     
     //----------------------------------
@@ -3104,8 +3296,14 @@ public class UIComponent extends UIBase
      */
     public function setFocus():void
     {
-        if (GOOG::DEBUG)
-            trace("setFocus not implemented");
+        COMPILE::SWF
+        {
+            stage.focus = this;
+        }
+        COMPILE::JS
+        {
+            element.focus();
+        }
     }
 
 

-- 
To stop receiving notification emails like this one, please contact
[email protected].

Reply via email to