示例#1
0
        internal void CommitElementUnderPointers(EventDispatcher dispatcher)
        {
            for (var i = 0; i < m_TopElementUnderPointer.Length; i++)
            {
                if (m_TopElementUnderPointer[i] == m_PendingTopElementUnderPointer[i])
                {
                    continue;
                }

                if (m_TriggerPointerEvent[i] == null && m_TriggerMouseEvent[i] == null)
                {
                    using (new EventDispatcherGate(dispatcher))
                    {
                        Vector2 position = PointerDeviceState.GetPointerPosition(i);

                        PointerEventsHelper.SendOverOut(m_TopElementUnderPointer[i],
                                                        m_PendingTopElementUnderPointer[i], null,
                                                        position, i);
                        PointerEventsHelper.SendEnterLeave <PointerLeaveEvent, PointerEnterEvent>(
                            m_TopElementUnderPointer[i], m_PendingTopElementUnderPointer[i], null, position, i);

                        if (i == PointerId.mousePointerId)
                        {
                            MouseEventsHelper.SendMouseOverMouseOut(m_TopElementUnderPointer[i],
                                                                    m_PendingTopElementUnderPointer[i],
                                                                    null, position);
                            MouseEventsHelper.SendEnterLeave <MouseLeaveEvent, MouseEnterEvent>(
                                m_TopElementUnderPointer[i], m_PendingTopElementUnderPointer[i], null, position);
                        }
                    }
                }

                if (m_TriggerPointerEvent[i] != null)
                {
                    if ((m_TriggerPointerEvent[i] as EventBase)?.eventTypeId == PointerMoveEvent.TypeId() ||
                        (m_TriggerPointerEvent[i] as EventBase)?.eventTypeId == PointerDownEvent.TypeId() ||
                        (m_TriggerPointerEvent[i] as EventBase)?.eventTypeId == PointerUpEvent.TypeId() ||
                        (m_TriggerPointerEvent[i] as EventBase)?.eventTypeId == PointerCancelEvent.TypeId())
                    {
                        using (new EventDispatcherGate(dispatcher))
                        {
                            PointerEventsHelper.SendOverOut(m_TopElementUnderPointer[i],
                                                            m_PendingTopElementUnderPointer[i],
                                                            m_TriggerPointerEvent[i], m_TriggerPointerEvent[i].position, i);
                            PointerEventsHelper.SendEnterLeave <PointerLeaveEvent, PointerEnterEvent>(
                                m_TopElementUnderPointer[i], m_PendingTopElementUnderPointer[i],
                                m_TriggerPointerEvent[i], m_TriggerPointerEvent[i].position, i);
                        }
                    }

                    m_TriggerPointerEvent[i] = null;
                }

                if (m_TriggerMouseEvent[i] != null)
                {
                    if ((m_TriggerMouseEvent[i] as EventBase)?.eventTypeId == MouseMoveEvent.TypeId() ||
                        (m_TriggerMouseEvent[i] as EventBase)?.eventTypeId == MouseDownEvent.TypeId() ||
                        (m_TriggerMouseEvent[i] as EventBase)?.eventTypeId == MouseUpEvent.TypeId() ||
                        (m_TriggerMouseEvent[i] as EventBase)?.eventTypeId == WheelEvent.TypeId())
                    {
                        using (new EventDispatcherGate(dispatcher))
                        {
                            MouseEventsHelper.SendMouseOverMouseOut(m_TopElementUnderPointer[i],
                                                                    m_PendingTopElementUnderPointer[i],
                                                                    m_TriggerMouseEvent[i], m_TriggerMouseEvent[i].mousePosition);
                            MouseEventsHelper.SendEnterLeave <MouseLeaveEvent, MouseEnterEvent>(
                                m_TopElementUnderPointer[i], m_PendingTopElementUnderPointer[i],
                                m_TriggerMouseEvent[i], m_TriggerMouseEvent[i].mousePosition);
                        }
                    }
                    else if ((m_TriggerMouseEvent[i] as EventBase)?.eventTypeId == MouseEnterWindowEvent.TypeId() ||
                             (m_TriggerMouseEvent[i] as EventBase)?.eventTypeId == MouseLeaveWindowEvent.TypeId()
                             )
                    {
                        using (new EventDispatcherGate(dispatcher))
                        {
                            PointerEventsHelper.SendOverOut(m_TopElementUnderPointer[i],
                                                            m_PendingTopElementUnderPointer[i], null,
                                                            m_TriggerMouseEvent[i].mousePosition, i);
                            PointerEventsHelper.SendEnterLeave <PointerLeaveEvent, PointerEnterEvent>(
                                m_TopElementUnderPointer[i], m_PendingTopElementUnderPointer[i], null,
                                m_TriggerMouseEvent[i].mousePosition, i);

                            if (i == PointerId.mousePointerId)
                            {
                                MouseEventsHelper.SendMouseOverMouseOut(m_TopElementUnderPointer[i],
                                                                        m_PendingTopElementUnderPointer[i],
                                                                        m_TriggerMouseEvent[i], m_TriggerMouseEvent[i].mousePosition);
                                MouseEventsHelper.SendEnterLeave <MouseLeaveEvent, MouseEnterEvent>(
                                    m_TopElementUnderPointer[i], m_PendingTopElementUnderPointer[i],
                                    m_TriggerMouseEvent[i], m_TriggerMouseEvent[i].mousePosition);
                            }
                        }
                    }
                    else if ((m_TriggerMouseEvent[i] as EventBase)?.eventTypeId == DragUpdatedEvent.TypeId() ||
                             (m_TriggerMouseEvent[i] as EventBase)?.eventTypeId == DragExitedEvent.TypeId())
                    {
                        using (new EventDispatcherGate(dispatcher))
                        {
                            PointerEventsHelper.SendOverOut(m_TopElementUnderPointer[i],
                                                            m_PendingTopElementUnderPointer[i], null,
                                                            m_TriggerMouseEvent[i].mousePosition, i);
                            PointerEventsHelper.SendEnterLeave <PointerLeaveEvent, PointerEnterEvent>(
                                m_TopElementUnderPointer[i], m_PendingTopElementUnderPointer[i], null,
                                m_TriggerMouseEvent[i].mousePosition, i);

                            MouseEventsHelper.SendMouseOverMouseOut(m_TopElementUnderPointer[i],
                                                                    m_PendingTopElementUnderPointer[i],
                                                                    m_TriggerMouseEvent[i], m_TriggerMouseEvent[i].mousePosition);
                            MouseEventsHelper.SendEnterLeave <MouseLeaveEvent, MouseEnterEvent>(
                                m_TopElementUnderPointer[i], m_PendingTopElementUnderPointer[i],
                                m_TriggerMouseEvent[i], m_TriggerMouseEvent[i].mousePosition);
                            MouseEventsHelper.SendEnterLeave <DragLeaveEvent, DragEnterEvent>(
                                m_TopElementUnderPointer[i], m_PendingTopElementUnderPointer[i],
                                m_TriggerMouseEvent[i], m_TriggerMouseEvent[i].mousePosition);
                        }
                    }

                    m_TriggerMouseEvent[i] = null;
                }

                m_TopElementUnderPointer[i] = m_PendingTopElementUnderPointer[i];
            }
        }
示例#2
0
        internal void CommitElementUnderPointers(EventDispatcher dispatcher)
        {
            for (var i = 0; i < m_TopElementUnderPointer.Length; i++)
            {
                var triggerPointerEvent = m_TriggerPointerEvent[i];
                var previous            = m_TopElementUnderPointer[i];
                var current             = m_PendingTopElementUnderPointer[i];

                if (current == previous)
                {
                    if (triggerPointerEvent != null)
                    {
                        var pos3d = triggerPointerEvent.position;
                        m_PickingPointerPositions[i] = new Vector2(pos3d.x, pos3d.y);
                    }
                    else if (m_TriggerMouseEvent[i] != null)
                    {
                        m_PickingPointerPositions[i] = m_TriggerMouseEvent[i].mousePosition;
                    }

                    continue;
                }

                m_TopElementUnderPointer[i] = current;

                if (triggerPointerEvent == null && m_TriggerMouseEvent[i] == null)
                {
                    using (new EventDispatcherGate(dispatcher))
                    {
                        Vector2 position = PointerDeviceState.GetPointerPosition(i);

                        PointerEventsHelper.SendOverOut(previous, current, null, position, i);
                        PointerEventsHelper.SendEnterLeave <PointerLeaveEvent, PointerEnterEvent>(
                            previous, current, null, position, i);

                        m_PickingPointerPositions[i] = position;
                        if (i == PointerId.mousePointerId)
                        {
                            MouseEventsHelper.SendMouseOverMouseOut(previous, current, null, position);
                            MouseEventsHelper.SendEnterLeave <MouseLeaveEvent, MouseEnterEvent>(
                                previous, current, null, position);
                        }
                    }
                }

                if (triggerPointerEvent != null)
                {
                    var pos3d = triggerPointerEvent.position;
                    m_PickingPointerPositions[i] = new Vector2(pos3d.x, pos3d.y);

                    var baseEvent = triggerPointerEvent as EventBase;
                    if (baseEvent != null && (
                            baseEvent.eventTypeId == PointerMoveEvent.TypeId() ||
                            baseEvent.eventTypeId == PointerDownEvent.TypeId() ||
                            baseEvent.eventTypeId == PointerUpEvent.TypeId() ||
                            baseEvent.eventTypeId == PointerCancelEvent.TypeId()))
                    {
                        using (new EventDispatcherGate(dispatcher))
                        {
                            PointerEventsHelper.SendOverOut(previous, current, triggerPointerEvent, pos3d, i);
                            PointerEventsHelper.SendEnterLeave <PointerLeaveEvent, PointerEnterEvent>(
                                previous, current, triggerPointerEvent, pos3d, i);
                        }
                    }
                }

                m_TriggerPointerEvent[i] = null;

                var triggerMouseEvent = m_TriggerMouseEvent[i];
                if (triggerMouseEvent != null)
                {
                    Vector2 mousePos = triggerMouseEvent.mousePosition;
                    m_PickingPointerPositions[i] = mousePos;
                    var baseEvent = triggerMouseEvent as EventBase;
                    if (baseEvent != null)
                    {
                        if (baseEvent.eventTypeId == MouseMoveEvent.TypeId() ||
                            baseEvent.eventTypeId == MouseDownEvent.TypeId() ||
                            baseEvent.eventTypeId == MouseUpEvent.TypeId() ||
                            baseEvent.eventTypeId == WheelEvent.TypeId())
                        {
                            using (new EventDispatcherGate(dispatcher))
                            {
                                MouseEventsHelper.SendMouseOverMouseOut(previous, current, triggerMouseEvent, mousePos);
                                MouseEventsHelper.SendEnterLeave <MouseLeaveEvent, MouseEnterEvent>(
                                    previous, current, triggerMouseEvent, mousePos);
                            }
                        }
                        else if (baseEvent.eventTypeId == MouseEnterWindowEvent.TypeId() ||
                                 baseEvent.eventTypeId == MouseLeaveWindowEvent.TypeId()
                                 )
                        {
                            using (new EventDispatcherGate(dispatcher))
                            {
                                PointerEventsHelper.SendOverOut(previous, current, null, mousePos, i);
                                PointerEventsHelper.SendEnterLeave <PointerLeaveEvent, PointerEnterEvent>(
                                    previous, current, null, mousePos, i);

                                if (i == PointerId.mousePointerId)
                                {
                                    MouseEventsHelper.SendMouseOverMouseOut(previous, current, triggerMouseEvent, mousePos);
                                    MouseEventsHelper.SendEnterLeave <MouseLeaveEvent, MouseEnterEvent>(
                                        previous, current, triggerMouseEvent, mousePos);
                                }
                            }
                        }
                        else if (baseEvent.eventTypeId == DragUpdatedEvent.TypeId() ||
                                 baseEvent.eventTypeId == DragExitedEvent.TypeId())
                        {
                            using (new EventDispatcherGate(dispatcher))
                            {
                                PointerEventsHelper.SendOverOut(previous, current, null, mousePos, i);
                                PointerEventsHelper.SendEnterLeave <PointerLeaveEvent, PointerEnterEvent>(
                                    previous, current, null, mousePos, i);

                                MouseEventsHelper.SendMouseOverMouseOut(previous, current, triggerMouseEvent, mousePos);
                                MouseEventsHelper.SendEnterLeave <MouseLeaveEvent, MouseEnterEvent>(
                                    previous, current, triggerMouseEvent, mousePos);
                                MouseEventsHelper.SendEnterLeave <DragLeaveEvent, DragEnterEvent>(
                                    previous, current, triggerMouseEvent, mousePos);
                            }
                        }
                    }

                    m_TriggerMouseEvent[i] = null;
                }
            }
        }