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 2021/01/24 20:39:03 UTC

[royale-asjs] branch develop updated: Fix for removing the correct Modal overlay for the current PopUp being removed. (This may not be the topmost overlay if the order of PopUp removal is not top-down)

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 09dff65  Fix for removing the correct Modal overlay for the current PopUp being removed. (This may not be the topmost overlay if the order of PopUp removal is not top-down)
09dff65 is described below

commit 09dff653caef2dfc5fe0d3de1926bf1c60b55c98
Author: greg-dove <gr...@gmail.com>
AuthorDate: Mon Jan 25 09:38:45 2021 +1300

    Fix for removing the correct Modal overlay for the current PopUp being removed. (This may not be the topmost overlay if the order of PopUp removal is not top-down)
---
 .../src/main/royale/mx/managers/PopUpManager.as    |  4 +-
 .../main/royale/mx/managers/PopUpManagerModal.as   | 48 ++++++++++++++--------
 2 files changed, 33 insertions(+), 19 deletions(-)

diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/managers/PopUpManager.as b/frameworks/projects/MXRoyale/src/main/royale/mx/managers/PopUpManager.as
index 2dd8003..b983558 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/managers/PopUpManager.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/managers/PopUpManager.as
@@ -201,7 +201,7 @@ public class PopUpManager
         var popUpHost:IPopUpHost = UIUtils.findPopUpHost(parent as IUIBase);
         if (modal)
         {
-            PopUpManagerModal.show(popUpHost as IUIBase);
+            PopUpManagerModal.show(popUpHost as IUIBase, window);
             modalWindows.push(window);
         }
         if (popUpHost is UIComponent)
@@ -260,7 +260,7 @@ public class PopUpManager
 			UIUtils.removePopUp(popUp as IChild);
             var modalIndex:int = modalWindows.indexOf(popUp);
             if (modalIndex != -1) {
-                PopUpManagerModal.remove(popUpHost);
+                PopUpManagerModal.remove(popUpHost, popUp);
                 modalWindows.splice(modalIndex,1);
             }
 		}
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/managers/PopUpManagerModal.as b/frameworks/projects/MXRoyale/src/main/royale/mx/managers/PopUpManagerModal.as
index 418dded..5597709 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/managers/PopUpManagerModal.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/managers/PopUpManagerModal.as
@@ -18,22 +18,16 @@
 ////////////////////////////////////////////////////////////////////////////////
 package mx.managers
 {
-  import org.apache.royale.events.EventDispatcher;
-  import org.apache.royale.core.IBead;
-  import org.apache.royale.core.IStrand;
   import org.apache.royale.core.IUIBase;
-  import org.apache.royale.core.IPopUpHost;
-  import org.apache.royale.events.Event;
-  import org.apache.royale.utils.UIUtils;
-  import org.apache.royale.events.IEventDispatcher;
   import org.apache.royale.core.IParent;
-  import org.apache.royale.core.IParentIUIBase;
-  import org.apache.royale.core.UIBase;
-  import org.apache.royale.utils.CSSUtils;
   import org.apache.royale.events.MouseEvent;
-
+  import mx.core.IFlexDisplayObject;
   import mx.core.UIComponent;
 
+  COMPILE::SWF{
+    import flash.utils.Dictionary
+  }
+
   public class PopUpManagerModal extends UIComponent
   {
     public function PopUpManagerModal()
@@ -41,15 +35,19 @@ package mx.managers
       super();
       typeNames = "PopUpManagerModal";
     }
-    
+
+    COMPILE::SWF
+    private static var overlaysByPopUp:Dictionary = new Dictionary();
+
+    COMPILE::JS
+    private static var overlaysByPopUp:Map = new Map();
 
     // Application and View are both possible parents,
     // but there's no single interface for both that will work.
-    private static var overlays:Array = [];
     /**
      *  @royaleignorecoercion Object
      */
-    public static function show(host:IUIBase):void
+    public static function show(host:IUIBase, forPopup:IFlexDisplayObject):void
     {
       var hostParent:IParent = host.parent;
       var overlay:PopUpManagerModal = new PopUpManagerModal();
@@ -78,7 +76,12 @@ package mx.managers
       */
       hostParent.addElement(overlay);
       overlay.addEventListener(MouseEvent.CLICK,handleClick);
-      overlays.push(overlay)
+      COMPILE::SWF{
+        overlaysByPopUp[forPopup] = overlay;
+      }
+      COMPILE::JS{
+        overlaysByPopUp.set(forPopup, overlay);
+      }
     }
 
     private static function handleClick(ev:MouseEvent):void
@@ -87,10 +90,21 @@ package mx.managers
       ev.stopImmediatePropagation();
     }
 
-    public static function remove(host:IUIBase):void
+    public static function remove(host:IUIBase, forPopup:IFlexDisplayObject):void
     {
         var hostParent:IParent = host.parent;
-        hostParent.removeElement(overlays.pop());
+      var overlay:PopUpManagerModal ;
+      COMPILE::SWF{
+        overlay = overlaysByPopUp[forPopup];
+        delete overlaysByPopUp[forPopup];
+      }
+      COMPILE::JS{
+        overlay = overlaysByPopUp.get(forPopup);
+        overlaysByPopUp.delete(forPopup);
+      }
+      if (overlay){
+        hostParent.removeElement(overlay);
+      }
     }