Example #1
0
        /// <summary>
        /// Changes the priority of a previously added delegate.
        /// The lower the number, the higher the priority
        /// </summary>
        public void setPriority(int nPriority, ICCTouchDelegate pDelegate)
        {
            CCTouchHandler handler = null;

            handler          = this.findHandler(pDelegate);
            handler.Priority = nPriority;

            this.rearrangeHandlers(m_pTargetedHandlers);
            this.rearrangeHandlers(m_pStandardHandlers);
        }
Example #2
0
        /// <summary>
        /// Adds a standard touch delegate to the dispatcher's list.
        /// See StandardTouchDelegate description.
        /// IMPORTANT: The delegate will be retained.
        /// </summary>
        public void addStandardDelegate(ICCStandardTouchDelegate pDelegate, int nPriority)
        {
            CCTouchHandler pHandler = CCStandardTouchHandler.handlerWithDelegate(pDelegate, nPriority);

            if (!m_bLocked)
            {
                forceAddHandler(pHandler, m_pStandardHandlers);
            }
            else
            {
                m_pHandlersToAdd.Add(pHandler);
                m_bToAdd = true;
            }
        }
Example #3
0
        /// <summary>
        /// Adds a targeted touch delegate to the dispatcher's list.
        /// See TargetedTouchDelegate description.
        /// IMPORTANT: The delegate will be retained.
        /// </summary>
        public void addTargetedDelegate(ICCTargetedTouchDelegate pDelegate, int nPriority, bool bSwallowsTouches)
        {
            CCTouchHandler pHandler = CCTargetedTouchHandler.handlerWithDelegate(pDelegate, nPriority, bSwallowsTouches);

            if (!m_bLocked)
            {
                forceAddHandler(pHandler, m_pTargetedHandlers);
            }
            else
            {
                m_pHandlersToAdd.Add(pHandler);
                m_bToAdd = true;
            }
        }
Example #4
0
        /// <summary>
        /// allocates a TouchHandler with a delegate and a priority
        /// </summary>
        public static CCTouchHandler handlerWithDelegate(ICCTouchDelegate pDelegate, int nPriority)
        {
            CCTouchHandler pHandler = new CCTouchHandler();

            if (pHandler.initWithDelegate(pDelegate, nPriority))
            {
                pHandler = null;
            }
            else
            {
                pHandler = null;
            }

            return(pHandler);
        }
Example #5
0
        protected void forceAddHandler(CCTouchHandler pHandler, List <CCTouchHandler> pArray)
        {
            int u = 0;

            for (int i = 0; i < pArray.Count; i++)
            {
                CCTouchHandler h = pArray[i];

                if (h != null)
                {
                    if (h.Priority < pHandler.Priority)
                    {
                        ++u;
                    }

                    if (h.Delegate == pHandler.Delegate)
                    {
                        return;
                    }
                }
            }

            pArray.Insert(u, pHandler);
        }
Example #6
0
 /// <summary>
 /// Used for sort
 /// </summary>
 int less(CCTouchHandler p1, CCTouchHandler p2)
 {
     return(p1.Priority - p2.Priority);
 }