static void GetChildEventBridges(string strType, Container container, List <EventBridge> bridges) { EventBridge bridge = container.TryGetEventBridge(strType); if (bridge != null) { bridges.Add(bridge); } if (container.gOwner != null) { bridge = container.gOwner.TryGetEventBridge(strType); if (bridge != null && !bridge.isEmpty) { bridges.Add(bridge); } } int count = container.numChildren; for (int i = 0; i < count; ++i) { DisplayObject obj = container.GetChildAt(i); if (obj is Container) { GetChildEventBridges(strType, (Container)obj, bridges); } else { bridge = obj.TryGetEventBridge(strType); if (bridge != null && !bridge.isEmpty) { bridges.Add(bridge); } if (obj.gOwner != null) { bridge = obj.gOwner.TryGetEventBridge(strType); if (bridge != null && !bridge.isEmpty) { bridges.Add(bridge); } } } } }
public bool BubbleEvent(string strType, object data) { EventContext context = EventContext.Get(); context.initiator = this; context._stopsPropagation = false; context._defaultPrevented = false; context.type = strType; context.data = data; List <EventBridge> bubbleChain = context.callChain; EventBridge bridge = TryGetEventBridge(strType); if (bridge != null && !bridge.isEmpty) { bubbleChain.Add(bridge); } if ((this is DisplayObject) && ((DisplayObject)this).gOwner != null) { bridge = ((DisplayObject)this).gOwner.TryGetEventBridge(strType); if (bridge != null && !bridge.isEmpty) { bubbleChain.Add(bridge); } } if (this is DisplayObject) { DisplayObject element = (DisplayObject)this; while ((element = element.parent) != null) { bridge = element.TryGetEventBridge(strType); if (bridge != null && !bridge.isEmpty) { bubbleChain.Add(bridge); } if (element.gOwner != null) { bridge = element.gOwner.TryGetEventBridge(strType); if (bridge != null && !bridge.isEmpty) { bubbleChain.Add(bridge); } } } } else if (this is GObject) { GObject element = (GObject)this; while ((element = element.parent) != null) { bridge = element.TryGetEventBridge(strType); if (bridge != null && !bridge.isEmpty) { bubbleChain.Add(bridge); } } } int length = bubbleChain.Count; for (int i = length - 1; i >= 0; i--) { bubbleChain[i].CallCaptureInternal(context); } for (int i = 0; i < length; ++i) { bubbleChain[i].CallInternal(context); if (context._stopsPropagation) { break; } } bubbleChain.Clear(); EventContext.Return(context); context.initiator = null; context.sender = null; context.data = null; return(context._defaultPrevented); }