Get() статический приватный Метод

static private Get ( ) : EventContext
Результат EventContext
Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="strType"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public bool BroadcastEvent(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;

            if (this is Container)
            {
                GetChildEventBridges(strType, (Container)this, bubbleChain);
            }
            else if (this is GComponent)
            {
                GetChildEventBridges(strType, (GComponent)this, bubbleChain);
            }

            int length = bubbleChain.Count;

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

            bubbleChain.Clear();
            EventContext.Return(context);
            context.initiator = null;
            context.sender    = null;
            context.data      = null;
            return(context._defaultPrevented);
        }
Пример #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);
            }
        }
        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);
            }
        }
Пример #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="strType"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public bool BroadcastEvent(string strType, object data)
        {
            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();

            if (this is Container)
            {
                GetChildEventBridges(strType, (Container)this, bubbleChain);
            }
            else if (this is GComponent)
            {
                GetChildEventBridges(strType, (GComponent)this, bubbleChain);
            }

            int length = bubbleChain.Count;

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

            var defaultPrevented = context._defaultPrevented;

            EventContext.Return(context);
            return(defaultPrevented);
        }
Пример #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="strType"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        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);
        }
Пример #6
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);
        }