flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [20/28] git commit: [flex-asjs] [refs/heads/develop] - add a way to get top level event dispatcher
Date Tue, 11 Nov 2014 22:08:36 GMT
add a way to get top level event dispatcher


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/6a9ea39a
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/6a9ea39a
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/6a9ea39a

Branch: refs/heads/develop
Commit: 6a9ea39a761c82f187718947364969e5117a044a
Parents: 0c9555c
Author: Alex Harui <aharui@apache.org>
Authored: Fri Nov 7 09:33:26 2014 -0800
Committer: Alex Harui <aharui@apache.org>
Committed: Tue Nov 11 14:07:59 2014 -0800

----------------------------------------------------------------------
 .../src/org/apache/flex/core/IUIBase.as         |  10 ++
 .../src/org/apache/flex/core/StageProxy.as      | 126 +++++++++++++++++++
 .../FlexJSUI/src/org/apache/flex/core/UIBase.as |  27 ++++
 .../src/org/apache/flex/core/UIButtonBase.as    |  16 +++
 .../supportClasses/TextFieldItemRenderer.as     |  17 +++
 5 files changed, 196 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/6a9ea39a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/IUIBase.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/IUIBase.as b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/IUIBase.as
index 4b2a72f..b033edc 100644
--- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/IUIBase.as
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/IUIBase.as
@@ -119,5 +119,15 @@ package org.apache.flex.core
         function get visible():Boolean;
         function set visible(value:Boolean):void;
         
+        /**
+         *  The top most event dispatcher.  Good for trying to capture
+         *  all input events.
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion FlexJS 0.0
+         */
+        function get topMostEventDispatcher():IEventDispatcher;
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/6a9ea39a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/StageProxy.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/StageProxy.as b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/StageProxy.as
new file mode 100644
index 0000000..879d2d5
--- /dev/null
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/StageProxy.as
@@ -0,0 +1,126 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.core
+{
+	import flash.display.Stage;
+    import flash.events.Event;
+	
+    import org.apache.flex.events.Event;
+	import org.apache.flex.events.IEventDispatcher;
+
+    /**
+     *  The StageProxy class wraps the stage and
+     *  presents it as a FlexJS IEventDispatcher.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 10.2
+     *  @playerversion AIR 2.6
+     *  @productversion FlexJS 0.0
+     */
+	public class StageProxy implements IEventDispatcher
+	{
+        /**
+         *  Constructor.
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion FlexJS 0.0
+         */
+		public function StageProxy(stage:Stage)
+		{
+			super();
+            _stage = stage;
+            _stage.addEventListener("removedFromStage", removedFromStageHandler);
+        }
+		
+		private var _stage:Stage;
+
+        private function removedFromStageHandler(event:flash.events.Event):void
+        {
+            _stage.removeEventListener("removedFromStage", removedFromStageHandler);
+            dispatchEvent(new org.apache.flex.events.Event("removedFromStage"));
+        }
+        
+        /**
+         *  @copy org.apache.flex.core.IEventDispatcher#addEventListener()
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion FlexJS 0.0
+         */
+		public function addEventListener(type:String, listener:Function, useCapture:Boolean = false,
priority:int = 0, useWeakReferences:Boolean = false):void	
+		{
+            _stage.addEventListener(type, listener, useCapture);
+		}
+       
+        /**
+         *  @copy org.apache.flex.core.IEventDispatcher#removeEventListener()
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion FlexJS 0.0
+         */
+        public function removeEventListener(type:String, listener:Function, useCapture:Boolean
= false):void	
+        {
+            _stage.removeEventListener(type, listener, useCapture);
+        }
+        
+        /**
+         *  @copy org.apache.flex.core.IEventDispatcher#removeEventListener()
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion FlexJS 0.0
+         */
+        public function dispatchEvent(event:flash.events.Event):Boolean	
+        {
+            return _stage.dispatchEvent(event);
+        }
+        
+        /**
+         *  @copy org.apache.flex.core.IEventDispatcher#willTriger()
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion FlexJS 0.0
+         */
+        public function willTrigger(eventName:String):Boolean	
+        {
+            return _stage.willTrigger(eventName);
+        }
+        
+        /**
+         *  @copy org.apache.flex.core.IEventDispatcher#hasEventListener()
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion FlexJS 0.0
+         */
+        public function hasEventListener(eventName:String):Boolean	
+        {
+            return _stage.hasEventListener(eventName);
+        }
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/6a9ea39a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/UIBase.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/UIBase.as b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/UIBase.as
index e837e36..c4a7c4f 100644
--- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/UIBase.as
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/UIBase.as
@@ -20,6 +20,7 @@ package org.apache.flex.core
 {
 	import flash.display.DisplayObject;
 	import flash.display.Sprite;
+	import flash.display.Stage;
 	
 	import org.apache.flex.events.Event;
 	import org.apache.flex.events.IEventDispatcher;
@@ -905,5 +906,31 @@ package org.apache.flex.core
 			return measurementBead;
 		}
         
+        private var _stageProxy:StageProxy;
+        
+        /**
+         *  @copy org.apache.flex.core.IUIBase#topMostEventDispatcher
+         * 
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion FlexJS 0.0
+         */
+		public function get topMostEventDispatcher():IEventDispatcher
+        {
+            if (!_stageProxy)
+            {
+                _stageProxy = new StageProxy(stage);
+                _stageProxy.addEventListener("removedFromStage", stageProxy_removedFromStageHandler);
+            }
+            
+            return _stageProxy;
+        }
+        
+        private function stageProxy_removedFromStageHandler(event:Event):void
+        {
+            _stageProxy = null;
+        }
+        
 	}
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/6a9ea39a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/UIButtonBase.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/UIButtonBase.as b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/UIButtonBase.as
index 226d69d..34b750c 100644
--- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/UIButtonBase.as
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/UIButtonBase.as
@@ -773,5 +773,21 @@ package org.apache.flex.core
 			return measurementBead;
 		}
         
+        /**
+         *  @copy org.apache.flex.core.IUIBase#topMostEventDispatcher
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion FlexJS 0.0
+         */
+        public function get topMostEventDispatcher():IEventDispatcher
+        {
+            if (!parent)
+                return null;
+            return IUIBase(parent).topMostEventDispatcher;
+        }
+
+        
 	}
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/6a9ea39a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/supportClasses/TextFieldItemRenderer.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/supportClasses/TextFieldItemRenderer.as
b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/supportClasses/TextFieldItemRenderer.as
index f349803..b49bac1 100644
--- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/supportClasses/TextFieldItemRenderer.as
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/supportClasses/TextFieldItemRenderer.as
@@ -28,6 +28,7 @@ package org.apache.flex.html.supportClasses
     import org.apache.flex.core.UIBase;
     import org.apache.flex.core.ValuesManager;
     import org.apache.flex.events.Event;
+    import org.apache.flex.events.IEventDispatcher;
     import org.apache.flex.events.MouseEvent;
     import org.apache.flex.events.utils.MouseEventConverter;
     import org.apache.flex.html.beads.ITextItemRenderer;
@@ -358,5 +359,21 @@ package org.apache.flex.html.supportClasses
                 }
             }
         }
+        
+        /**
+         *  @copy org.apache.flex.core.IUIBase#topMostEventDispatcher
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion FlexJS 0.0
+         */
+        public function get topMostEventDispatcher():IEventDispatcher
+        {
+            if (!parent)
+                return null;
+            return IUIBase(parent).topMostEventDispatcher;
+        }
+
     }
 }


Mime
View raw message