You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2013/10/11 08:46:02 UTC
[08/11] git commit: [flex-sdk] [refs/heads/release4.11.0] - Try to
support non-modal windows on top of a modal window
Try to support non-modal windows on top of a modal window
Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/1a4df288
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/1a4df288
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/1a4df288
Branch: refs/heads/release4.11.0
Commit: 1a4df2886ef669bb8a1a87d38c6502bf5a798933
Parents: 9c5f91e
Author: Alex Harui <ah...@apache.org>
Authored: Thu Sep 5 09:53:08 2013 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Thu Oct 10 23:18:38 2013 -0700
----------------------------------------------------------------------
.../systemClasses/ActiveWindowManager.as | 205 +++++++++++--------
1 file changed, 117 insertions(+), 88 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/1a4df288/frameworks/projects/framework/src/mx/managers/systemClasses/ActiveWindowManager.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/framework/src/mx/managers/systemClasses/ActiveWindowManager.as b/frameworks/projects/framework/src/mx/managers/systemClasses/ActiveWindowManager.as
index 203f46a..43a083f 100644
--- a/frameworks/projects/framework/src/mx/managers/systemClasses/ActiveWindowManager.as
+++ b/frameworks/projects/framework/src/mx/managers/systemClasses/ActiveWindowManager.as
@@ -25,16 +25,16 @@ import flash.display.InteractiveObject;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.EventDispatcher;
-import flash.events.IEventDispatcher;
import flash.events.FocusEvent;
+import flash.events.IEventDispatcher;
import flash.events.MouseEvent;
import mx.core.IChildList;
import mx.core.IFlexModuleFactory;
import mx.core.IRawChildrenContainer;
import mx.core.IUIComponent;
-import mx.core.mx_internal;
import mx.core.Singleton;
+import mx.core.mx_internal;
import mx.events.DynamicEvent;
import mx.events.Request;
import mx.managers.IActiveWindowManager;
@@ -428,6 +428,30 @@ public class ActiveWindowManager extends EventDispatcher implements IActiveWindo
/**
* @private
+ */
+ private function findHighestModalForm():int
+ {
+ var n:int = forms.length;
+ var rc:IChildList = systemManager.rawChildren;
+ for (var i:int = n - 1; n >= 0; i--)
+ {
+ var f:Object = forms[i];
+ if (f is DisplayObject)
+ {
+ var index:int = rc.getChildIndex(f as DisplayObject);
+ if (index > 0)
+ {
+ var under:DisplayObject = rc.getChildAt(index - 1);
+ if (under.name == "modalWindow")
+ return i;
+ }
+ }
+ }
+ return 0;
+ }
+
+ /**
+ * @private
* Track mouse clicks to see if we change top-level forms.
*/
private function mouseDownHandler(event:MouseEvent):void
@@ -437,106 +461,111 @@ public class ActiveWindowManager extends EventDispatcher implements IActiveWindo
if (!dispatchEvent(new FocusEvent(MouseEvent.MOUSE_DOWN, false, true, InteractiveObject(event.target))))
return;
- if (numModalWindows == 0) // no modal windows are up
+ var startIndex:int = 0;
+ if (numModalWindows > 0)
{
- if (!systemManager.isTopLevelRoot() || forms.length > 1)
+ // if there is a modal window, only non-modal
+ // windows above it are in play
+ startIndex = findHighestModalForm() + 1;
+ }
+
+ if (!systemManager.isTopLevelRoot() || forms.length > 1)
+ {
+ var n:int = forms.length;
+ var p:DisplayObject = DisplayObject(event.target);
+ var isApplication:Boolean = systemManager.document is IRawChildrenContainer ?
+ IRawChildrenContainer(systemManager.document).rawChildren.contains(p) :
+ systemManager.document.contains(p);
+ while (p)
{
- var n:int = forms.length;
- var p:DisplayObject = DisplayObject(event.target);
- var isApplication:Boolean = systemManager.document is IRawChildrenContainer ?
- IRawChildrenContainer(systemManager.document).rawChildren.contains(p) :
- systemManager.document.contains(p);
- while (p)
+ for (var i:int = startIndex; i < n; i++)
{
- for (var i:int = 0; i < n; i++)
+ var form_i:Object = forms[i];
+ if (hasEventListener("actualForm"))
+ {
+ var request:Request = new Request("actualForm", false, true);
+ request.value = forms[i];
+ if (!dispatchEvent(request))
+ form_i = forms[i].window;
+ }
+ if (form_i == p)
{
- var form_i:Object = forms[i];
- if (hasEventListener("actualForm"))
- {
- var request:Request = new Request("actualForm", false, true);
- request.value = forms[i];
- if (!dispatchEvent(request))
- form_i = forms[i].window;
- }
- if (form_i == p)
- {
- var j:int = 0;
- var index:int;
- var newIndex:int;
- var childList:IChildList;
+ var j:int = 0;
+ var index:int;
+ var newIndex:int;
+ var childList:IChildList;
- if (((p != form) && p is IFocusManagerContainer) ||
- (!systemManager.isTopLevelRoot() && p == form))
+ if (((p != form) && p is IFocusManagerContainer) ||
+ (!systemManager.isTopLevelRoot() && p == form))
+ {
+ if (systemManager.isTopLevelRoot())
+ activate(IFocusManagerContainer(p));
+
+ if (p == systemManager.document)
+ {
+ if (hasEventListener("activateApplication"))
+ dispatchEvent(new Event("activateApplication"));
+ }
+ else if (p is DisplayObject)
+ {
+ if (hasEventListener("activateWindow"))
+ dispatchEvent(new FocusEvent("activateWindow", false, false, InteractiveObject(p)));
+ }
+ }
+
+ if (systemManager.popUpChildren.contains(p))
+ childList = systemManager.popUpChildren;
+ else
+ childList = systemManager;
+
+ index = childList.getChildIndex(p);
+ newIndex = index;
+
+ //we need to reset n because activating p's
+ //FocusManager could have caused
+ //forms.length to have changed.
+ n = forms.length;
+ for (j = startIndex; j < n; j++)
+ {
+ var f:DisplayObject;
+ isRemotePopUp = false;
+ if (hasEventListener("isRemote"))
+ {
+ request = new Request("isRemote", false, true);
+ request.value = forms[j];
+ var isRemotePopUp:Boolean = false;
+ if (!dispatchEvent(request))
+ isRemotePopUp = request.value as Boolean;
+ }
+ if (isRemotePopUp)
{
- if (systemManager.isTopLevelRoot())
- activate(IFocusManagerContainer(p));
-
- if (p == systemManager.document)
- {
- if (hasEventListener("activateApplication"))
- dispatchEvent(new Event("activateApplication"));
- }
- else if (p is DisplayObject)
- {
- if (hasEventListener("activateWindow"))
- dispatchEvent(new FocusEvent("activateWindow", false, false, InteractiveObject(p)));
- }
+ if (forms[j].window is String)
+ continue;
+ f = forms[j].window;
}
-
- if (systemManager.popUpChildren.contains(p))
- childList = systemManager.popUpChildren;
- else
- childList = systemManager;
-
- index = childList.getChildIndex(p);
- newIndex = index;
-
- //we need to reset n because activating p's
- //FocusManager could have caused
- //forms.length to have changed.
- n = forms.length;
- for (j = 0; j < n; j++)
+ else
+ f = forms[j];
+ if (isRemotePopUp)
{
- var f:DisplayObject;
- isRemotePopUp = false;
- if (hasEventListener("isRemote"))
- {
- request = new Request("isRemote", false, true);
- request.value = forms[j];
- var isRemotePopUp:Boolean = false;
- if (!dispatchEvent(request))
- isRemotePopUp = request.value as Boolean;
- }
- if (isRemotePopUp)
- {
- if (forms[j].window is String)
- continue;
- f = forms[j].window;
- }
- else
- f = forms[j];
- if (isRemotePopUp)
- {
- var fChildIndex:int = getChildListIndex(childList, f);
- if (fChildIndex > index)
- newIndex = Math.max(fChildIndex, newIndex);
- }
- else if (childList.contains(f))
- if (childList.getChildIndex(f) > index)
- newIndex = Math.max(childList.getChildIndex(f), newIndex);
+ var fChildIndex:int = getChildListIndex(childList, f);
+ if (fChildIndex > index)
+ newIndex = Math.max(fChildIndex, newIndex);
}
- if (newIndex > index && !isApplication)
- childList.setChildIndex(p, newIndex);
-
- return;
+ else if (childList.contains(f))
+ if (childList.getChildIndex(f) > index)
+ newIndex = Math.max(childList.getChildIndex(f), newIndex);
}
+ if (newIndex > index && !isApplication)
+ childList.setChildIndex(p, newIndex);
+
+ return;
}
- p = p.parent;
}
+ p = p.parent;
}
- else if (hasEventListener("activateApplication"))
- dispatchEvent(new Event("activateApplication"));
}
+ else if (hasEventListener("activateApplication"))
+ dispatchEvent(new Event("activateApplication"));
}
/**