static void GetChildEventListeners(string strType, Container container, List <EventListener> listeners) { EventListener listener = container.GetEventListener(strType); if (listener != null) { listeners.Add(listener); } if (container.gOwner != null) { listener = container.gOwner.GetEventListener(strType); if (listener != null && !listener.isEmpty) { listeners.Add(listener); } } int count = container.numChildren; for (int i = 0; i < count; ++i) { DisplayObject obj = container.GetChildAt(i); if (obj is Container) { GetChildEventListeners(strType, (Container)obj, listeners); } else { listener = obj.GetEventListener(strType); if (listener != null && !listener.isEmpty) { listeners.Add(listener); } if (obj.gOwner != null) { listener = obj.gOwner.GetEventListener(strType); if (listener != null && !listener.isEmpty) { listeners.Add(listener); } } } } }
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 <EventListener> bubbleChain = context.callChain; EventListener listener = GetEventListener(strType); if (listener != null && !listener.isEmpty) { bubbleChain.Add(listener); } if ((this is DisplayObject) && ((DisplayObject)this).gOwner != null) { listener = ((DisplayObject)this).gOwner.GetEventListener(strType); if (listener != null && !listener.isEmpty) { bubbleChain.Add(listener); } } if (this is DisplayObject) { DisplayObject element = (DisplayObject)this; while ((element = element.parent) != null) { listener = element.GetEventListener(strType); if (listener != null && !listener.isEmpty) { bubbleChain.Add(listener); } if (element.gOwner != null) { listener = element.gOwner.GetEventListener(strType); if (listener != null && !listener.isEmpty) { bubbleChain.Add(listener); } } } } else if (this is GObject) { GObject element = (GObject)this; while ((element = element.parent) != null) { listener = element.GetEventListener(strType); if (listener != null && !listener.isEmpty) { bubbleChain.Add(listener); } } } 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); }