You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by gr...@apache.org on 2020/08/25 04:54:45 UTC

[royale-asjs] branch develop updated: Adding containerContains for hierarchy check.

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

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


The following commit(s) were added to refs/heads/develop by this push:
     new a220b36  Adding containerContains for hierarchy check.
a220b36 is described below

commit a220b3687beb12e1eaa8c9025e2a73502c7ae3f1
Author: greg-dove <gr...@gmail.com>
AuthorDate: Tue Aug 25 16:45:18 2020 +1200

    Adding containerContains for hierarchy check.
---
 .../royale/org/apache/royale/utils/DisplayUtils.as | 29 ++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/DisplayUtils.as b/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/DisplayUtils.as
index 5e85db1..e3894ea 100644
--- a/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/DisplayUtils.as
+++ b/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/DisplayUtils.as
@@ -18,20 +18,23 @@
 ////////////////////////////////////////////////////////////////////////////////
 package org.apache.royale.utils
 {
-	
+
+	import org.apache.royale.core.IParent;
 	import org.apache.royale.core.IUIBase;
 	import org.apache.royale.geom.Matrix;
 	import org.apache.royale.geom.Rectangle;
+	import org.apache.royale.core.IRenderedObject;
 
 	COMPILE::SWF
 	{
 		import flash.geom.Matrix;
+		import flash.display.DisplayObjectContainer;
+		import flash.display.DisplayObject;
 	}
 	
 	COMPILE::JS 
 	{
 		import org.apache.royale.geom.Point;
-		import org.apache.royale.geom.Point;
 		import org.apache.royale.core.ITransformHost;
 	}
 	/**
@@ -220,6 +223,28 @@ package org.apache.royale.utils
 		    return elements;
 		}
 
+		/**
+		 *  Determines if the potentialChild has the container somewhere in its parent hierarchy.
+		 *
+		 *  @param container The container to check
+		 *  @param potentialChild The target to verify as part of the child tree below the container
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion Royale 0.0
+		 *  @royaleignorecoercion org.apache.royale.core.IRenderedObject
+		 *
+		 */
+		public static function containerContains(container:IParent, potentialChild:IUIBase):Boolean{
+			COMPILE::SWF{
+				return container is DisplayObjectContainer && potentialChild is DisplayObject && DisplayObjectContainer(container).contains(DisplayObject(potentialChild));
+			}
+			COMPILE::JS{
+				return container is IRenderedObject && IRenderedObject(container).element.contains(potentialChild.element);
+			}
+		}
+
 	}
 
 }