public bool DispatchEvent(EventContext context)
        {
            EventListener listener  = GetEventListener(context.type);
            EventListener gListener = null;

            if ((this is DisplayObject) && ((DisplayObject)this).gOwner != null)
            {
                gListener = ((DisplayObject)this).gOwner.GetEventListener(context.type);
            }

            EventDispatcher savedSender = context.sender;

            if (listener != null && !listener.isEmpty)
            {
                listener.CallCaptureInternal(context);
                listener.CallInternal(context);
            }

            if (gListener != null && !gListener.isEmpty)
            {
                gListener.CallCaptureInternal(context);
                gListener.CallInternal(context);
            }

            context.sender = savedSender;
            return(context._defaultPrevented);
        }
        internal bool InternalDispatchEvent(string strType, EventListener listener, object data)
        {
            EventListener gListener = null;

            if ((this is DisplayObject) && ((DisplayObject)this).gOwner != null)
            {
                gListener = ((DisplayObject)this).gOwner.GetEventListener(strType);
            }

            bool b1 = listener != null && !listener.isEmpty;
            bool b2 = gListener != null && !gListener.isEmpty;

            if (b1 || b2)
            {
                EventContext context = EventContext.Get();
                context.initiator         = this;
                context._stopsPropagation = false;
                context._defaultPrevented = false;
                context.type = strType;
                context.data = data;

                if (b1)
                {
                    listener.CallCaptureInternal(context);
                    listener.CallInternal(context);
                }

                if (b2)
                {
                    gListener.CallCaptureInternal(context);
                    gListener.CallInternal(context);
                }

                EventContext.Return(context);
                context.initiator = null;
                context.sender    = null;
                context.data      = null;

                return(context._defaultPrevented);
            }
            else
            {
                return(false);
            }
        }
예제 #3
0
        internal bool InternalDispatchEvent(string strType, EventListener listener, object data)
        {
            EventListener gListener = null;
            if ((this is DisplayObject) && ((DisplayObject)this).gOwner != null)
                gListener = ((DisplayObject)this).gOwner.GetEventListener(strType);

            bool b1 = listener != null && !listener.isEmpty;
            bool b2 = gListener != null && !gListener.isEmpty;
            if (b1 || b2)
            {
                EventContext context = EventContext.Get();
                context.initiator = this;
                context._stopsPropagation = false;
                context._defaultPrevented = false;
                context.type = strType;
                context.data = data;

                if (b1)
                {
                    listener.CallCaptureInternal(context);
                    listener.CallInternal(context);
                }

                if (b2)
                {
                    gListener.CallCaptureInternal(context);
                    gListener.CallInternal(context);
                }

                EventContext.Return(context);
                context.initiator = null;
                context.sender = null;
                context.data = null;

                return context._defaultPrevented;
            }
            else
                return false;
        }