CallCaptureInternal() public method

public CallCaptureInternal ( EventContext context ) : void
context EventContext
return void
Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public bool DispatchEvent(EventContext context)
        {
            EventBridge bridge  = TryGetEventBridge(context.type);
            EventBridge gBridge = null;

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

            EventDispatcher savedSender = context.sender;

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

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

            context.sender = savedSender;
            return(context._defaultPrevented);
        }
Ejemplo n.º 2
0
        internal bool InternalDispatchEvent(string strType, EventBridge bridge, object data, object initiator)
        {
            if (bridge == null)
            {
                bridge = TryGetEventBridge(strType);
            }

            EventBridge gBridge = null;

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

            bool b1 = bridge != null && !bridge.isEmpty;
            bool b2 = gBridge != null && !gBridge.isEmpty;

            if (b1 || b2)
            {
                EventContext context = EventContext.Get();
                context.initiator = initiator != null ? initiator : this;
                context.type      = strType;
                context.data      = data;
                if (data is InputEvent)
                {
                    sCurrentInputEvent = (InputEvent)data;
                }
                context.inputEvent = sCurrentInputEvent;

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

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

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

                return(context._defaultPrevented);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="strType"></param>
        /// <param name="data"></param>
        /// <param name="addChain"></param>
        /// <returns></returns>
        internal bool BubbleEvent(string strType, object data, List <EventBridge> addChain)
        {
            EventContext context = EventContext.Get();

            context.initiator = this;

            context.type = strType;
            context.data = data;
            if (data is InputEvent)
            {
                sCurrentInputEvent = (InputEvent)data;
            }
            context.inputEvent = sCurrentInputEvent;
            List <EventBridge> bubbleChain = context.callChain;

            bubbleChain.Clear();

            GetChainBridges(strType, bubbleChain, true);

            int length = bubbleChain.Count;

            for (int i = length - 1; i >= 0; i--)
            {
                bubbleChain[i].CallCaptureInternal(context);
                if (context._touchCapture)
                {
                    context._touchCapture = false;
                    if (strType == "onTouchBegin")
                    {
                        Stage.inst.AddTouchMonitor(context.inputEvent.touchId, bubbleChain[i].owner);
                    }
                }
            }

            if (!context._stopsPropagation)
            {
                for (int i = 0; i < length; ++i)
                {
                    bubbleChain[i].CallInternal(context);

                    if (context._touchCapture)
                    {
                        context._touchCapture = false;
                        if (strType == "onTouchBegin")
                        {
                            Stage.inst.AddTouchMonitor(context.inputEvent.touchId, bubbleChain[i].owner);
                        }
                    }

                    if (context._stopsPropagation)
                    {
                        break;
                    }
                }

                if (addChain != null)
                {
                    length = addChain.Count;
                    for (int i = 0; i < length; ++i)
                    {
                        EventBridge bridge = addChain[i];
                        if (bubbleChain.IndexOf(bridge) == -1)
                        {
                            bridge.CallCaptureInternal(context);
                            bridge.CallInternal(context);
                        }
                    }
                }
            }

            var defaultPrevented = context._defaultPrevented;

            EventContext.Return(context);
            return(defaultPrevented);
        }
Ejemplo n.º 4
0
        internal bool InternalDispatchEvent(string strType, EventBridge bridge, object data, object initiator)
        {
            EventBridge gBridge = null;
            if ((this is DisplayObject) && ((DisplayObject)this).gOwner != null)
                gBridge = ((DisplayObject)this).gOwner.TryGetEventBridge(strType);

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

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

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

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

                return context._defaultPrevented;
            }
            else
                return false;
        }