royale-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [royale-asjs] 08/09: resurrect more of the UIComponent lifecycle and get initialize event working
Date Thu, 12 Apr 2018 23:00:42 GMT
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 95b59237e802fe774f42a6bb044ca5dec32f05b9
Author: Alex Harui <aharui@apache.org>
AuthorDate: Thu Apr 12 15:59:35 2018 -0700

    resurrect more of the UIComponent lifecycle and get initialize event working
---
 .../src/main/royale/mx/core/Application.as         | 33 ++++++++++++++++------
 .../MXRoyale/src/main/royale/mx/core/Container.as  | 21 +++++++-------
 .../src/main/royale/mx/core/UIComponent.as         | 29 +++++++++++++++++--
 3 files changed, 61 insertions(+), 22 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 82db42e..b04705d 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/core/Application.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/core/Application.as
@@ -366,7 +366,7 @@ public class Application extends Container implements IStrand, IParent,
IEventDi
 		MouseEventConverter.setupAllConverters(stage);
 		
 		if (dispatchEvent(new org.apache.royale.events.Event("preinitialize", false, true)))
-			this.initialize();
+			this.initializeApplication();
 		else
 			addEventListener(flash.events.Event.ENTER_FRAME, enterFrameHandler);
 		
@@ -378,7 +378,7 @@ public class Application extends Container implements IStrand, IParent,
IEventDi
 		if (dispatchEvent(new org.apache.royale.events.Event("preinitialize", false, true)))
 		{
 			removeEventListener(flash.events.Event.ENTER_FRAME, enterFrameHandler);
-			this.initialize();
+			this.initializeApplication();
 		}
 	}
 	
@@ -392,7 +392,7 @@ public class Application extends Container implements IStrand, IParent,
IEventDi
 	 *  @productversion Royale 0.0
 	 */
     COMPILE::SWF
-    override public function initialize():void
+    public function initializeApplication():void
     {
         addBead(new MixinManager());
         // the application is never added to the dom via addChild
@@ -402,7 +402,6 @@ public class Application extends Container implements IStrand, IParent,
IEventDi
         
 		this.initManagers();
 
-        dispatchEvent(new org.apache.royale.events.Event("initialize"));
         dispatchEvent(new org.apache.royale.events.Event("applicationComplete"));
     }
 	
@@ -516,7 +515,7 @@ public class Application extends Container implements IStrand, IParent,
IEventDi
 	public function start():void
 	{
 		if (dispatchEvent(new org.apache.royale.events.Event("preinitialize", false, true)))
-			initialize();
+			initializeApplication();
 		else {			
 			startupTimer = new Timer(34, 0);
 			startupTimer.addEventListener("timer", handleStartupTimer);
@@ -533,7 +532,7 @@ public class Application extends Container implements IStrand, IParent,
IEventDi
 		if (dispatchEvent(new org.apache.royale.events.Event("preinitialize", false, true)))
 		{
 			startupTimer.stop();
-			initialize();
+			initializeApplication();
 		}
 	}
 	
@@ -541,7 +540,7 @@ public class Application extends Container implements IStrand, IParent,
IEventDi
 	 * @royaleignorecoercion org.apache.royale.core.IBead
 	 */
 	COMPILE::JS
-	override public function initialize():void
+	public function initializeApplication():void
 	{
 		var body:HTMLElement = document.getElementsByTagName('body')[0];
 		body.appendChild(element);
@@ -554,8 +553,6 @@ public class Application extends Container implements IStrand, IParent,
IEventDi
         
 		addedToParent();
         		
-		dispatchEvent('initialize');
-		
 //		if (initialView)
 //		{
 //            initialView.applicationModel = model;
@@ -601,6 +598,24 @@ public class Application extends Container implements IStrand, IParent,
IEventDi
 		// Setting this directly doesn't do anything
 	}
 
+    //--------------------------------------------------------------------------
+    //
+    //  IPopUpHost
+    //
+    //--------------------------------------------------------------------------
+    
+    /**
+     *  Application can host popups but in the strandChildren
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 10.2
+     *  @playerversion AIR 2.6
+     *  @productversion Royale 0.0
+     */
+    public function get popUpParent():IParent
+    {
+        return strandChildren;
+    }
 }
 
 }
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 3650819..b497c30 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/core/Container.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/core/Container.as
@@ -475,11 +475,10 @@ public class Container extends UIComponent
 	
 	private var _mxmlDescriptor:Array;
 	private var _mxmlDocument:Object = this;
-	private var _initialized:Boolean;
 	
 	override public function addedToParent():void
 	{
-		if (!_initialized) {
+		if (!initialized) {
 			// each MXML file can also have styles in fx:Style block
 			ValuesManager.valuesImpl.init(this);
 		}
@@ -487,21 +486,21 @@ public class Container extends UIComponent
         if (MXMLDescriptor)
             component = this;
         
-		super.addedToParent();
-		
-		if (!_initialized) {
-			MXMLDataInterpreter.generateMXMLInstances(_mxmlDocument, this, MXMLDescriptor);
-			
-			dispatchEvent(new Event("initBindings"));
-			dispatchEvent(new Event("initComplete"));
-			_initialized = true;
-		}
+		super.addedToParent();		
 		
 		// Load the layout bead if it hasn't already been loaded.
 		if (loadBeadFromValuesManager(IBeadLayout, "iBeadLayout", this))
 			dispatchEvent(new Event("layoutNeeded"));
 	}
 	
+    override protected function createChildren():void
+    {
+        MXMLDataInterpreter.generateMXMLInstances(_mxmlDocument, this, MXMLDescriptor);
+        
+        dispatchEvent(new Event("initBindings"));
+        dispatchEvent(new Event("initComplete"));
+    }
+    
 	/**
 	 *  @copy org.apache.royale.core.Application#MXMLDescriptor
 	 *  
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 4411d5b..8f12f62 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/core/UIComponent.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/core/UIComponent.as
@@ -93,6 +93,24 @@ import mx.validators.ValidationResult;
 use namespace mx_internal;
 */
 
+/**
+ *  Dispatched when the component has finished its construction
+ *  and has all initialization properties set.
+ *
+ *  <p>After the initialization phase, properties are processed, the component
+ *  is measured, laid out, and drawn, after which the
+ *  <code>creationComplete</code> event is dispatched.</p>
+ * 
+ *  @eventType mx.events.FlexEvent.INITIALIZE
+ *  
+ *  @langversion 3.0
+ *  @playerversion Flash 9
+ *  @playerversion AIR 1.1
+ *  @productversion Flex 3
+ */
+[Event(name="initialize", type="mx.events.FlexEvent")]
+
+
 // Excluding the property to enable code hinting for the layoutDirection style
 [Exclude(name="layoutDirection", kind="property")]
 
@@ -926,9 +944,17 @@ public class UIComponent extends UIBase
         _component = value;
     }
     
+    
     override public function addedToParent():void
     {
         super.addedToParent();
+        
+        if (!initialized)
+        {
+            initialize();
+            initialized = true;
+        }
+
         if (!component && parent is UIComponent)
             component = UIComponent(parent).component;
         else if (!component && parent is ContainerContentArea)
@@ -2460,6 +2486,7 @@ public class UIComponent extends UIBase
      */
     protected function initializationComplete():void
     {
+        dispatchEvent(new FlexEvent(FlexEvent.INITIALIZE));
     }
     
     /**
@@ -2487,8 +2514,6 @@ public class UIComponent extends UIBase
      */
     protected function createChildren():void
     {
-        if (GOOG::DEBUG)
-            trace("createChildren not implemented");
     }
     
 

-- 
To stop receiving notification emails like this one, please contact
aharui@apache.org.

Mime
View raw message