Beispiel #1
0
        void OnPointerMove(PointerMoveEvent evt)
        {
            m_MousePosition = m_ScrollView.WorldToLocal(evt.position);
            UpdateSelection(evt.target as VisualElement);

            if (evt.pointerId != PointerId.mousePointerId)
            {
                m_MenuContainer.panel.PreventCompatibilityMouseEvents(evt.pointerId);
            }

            evt.StopPropagation();
        }
        private void OnPointerMoveEvent(PointerMoveEvent evt)
        {
            if (useDragEvents)
            {
                if (m_DragState != DragState.CanStartDrag)
                {
                    return;
                }
            }
            else
            {
                if (m_DragState == DragState.Dragging)
                {
                    UpdateDrag(evt.position);
                    return;
                }

                if (m_DragState != DragState.CanStartDrag)
                {
                    return;
                }
            }

            if (Mathf.Abs(m_Start.x - evt.position.x) > k_DistanceToActivation ||
                Mathf.Abs(m_Start.y - evt.position.y) > k_DistanceToActivation)
            {
                var startDragArgs = StartDrag(m_Start);

                if (useDragEvents)
                {
                    // Drag can only be started by mouse events or else it will throw an error, so we leave early.
                    if (Event.current.type != EventType.MouseDown && Event.current.type != EventType.MouseDrag)
                    {
                        return;
                    }

                    DragAndDropUtility.dragAndDrop.StartDrag(startDragArgs);
                }
                else // Force default drag and drop client for runtime panels.
                {
                    m_Target.CapturePointer(evt.pointerId);
                    evt.StopPropagation();

                    dragAndDropClient = new DefaultDragAndDropClient();
                    dragAndDropClient.StartDrag(startDragArgs);
                }

                m_DragState = DragState.Dragging;
            }
        }
Beispiel #3
0
        private void OnPointerMove(PointerMoveEvent evt)
        {
            bool flag = evt.pointerId == this.m_ScrollingPointerId;

            if (flag)
            {
                bool    flag2 = this.touchScrollBehavior == ScrollView.TouchScrollBehavior.Clamped;
                Vector2 vector;
                if (flag2)
                {
                    vector = this.m_StartPosition - (new Vector2(evt.position.x, evt.position.y) - this.m_PointerStartPosition);
                    vector = Vector2.Max(vector, this.m_LowBounds);
                    vector = Vector2.Min(vector, this.m_HighBounds);
                }
                else
                {
                    bool flag3 = this.touchScrollBehavior == ScrollView.TouchScrollBehavior.Elastic;
                    if (flag3)
                    {
                        Vector2 vector2 = new Vector2(evt.position.x, evt.position.y) - this.m_PointerStartPosition;
                        vector.x = ScrollView.ComputeElasticOffset(vector2.x, this.m_StartPosition.x, this.m_LowBounds.x, this.m_LowBounds.x - this.contentViewport.resolvedStyle.width, this.m_HighBounds.x, this.m_HighBounds.x + this.contentViewport.resolvedStyle.width);
                        vector.y = ScrollView.ComputeElasticOffset(vector2.y, this.m_StartPosition.y, this.m_LowBounds.y, this.m_LowBounds.y - this.contentViewport.resolvedStyle.height, this.m_HighBounds.y, this.m_HighBounds.y + this.contentViewport.resolvedStyle.height);
                    }
                    else
                    {
                        vector = this.m_StartPosition - (new Vector2(evt.position.x, evt.position.y) - this.m_PointerStartPosition);
                    }
                }
                bool hasInertia = this.hasInertia;
                if (hasInertia)
                {
                    float   unscaledDeltaTime = Time.unscaledDeltaTime;
                    Vector2 b = (vector - this.scrollOffset) / unscaledDeltaTime;
                    this.m_Velocity = Vector2.Lerp(this.m_Velocity, b, unscaledDeltaTime * 10f);
                }
                this.scrollOffset = vector;
                evt.currentTarget.CapturePointer(evt.pointerId);
                evt.StopPropagation();
            }
        }
Beispiel #4
0
        void OnPointerMove(PointerMoveEvent evt)
        {
            if (evt.pointerId == m_ScrollingPointerId)
            {
                Vector2 newScrollOffset;
                if (touchScrollBehavior == TouchScrollBehavior.Clamped)
                {
                    newScrollOffset = m_StartPosition - (new Vector2(evt.position.x, evt.position.y) - m_PointerStartPosition);
                    newScrollOffset = Vector2.Max(newScrollOffset, m_LowBounds);
                    newScrollOffset = Vector2.Min(newScrollOffset, m_HighBounds);
                }
                else if (touchScrollBehavior == TouchScrollBehavior.Elastic)
                {
                    Vector2 deltaPointer = new Vector2(evt.position.x, evt.position.y) - m_PointerStartPosition;
                    newScrollOffset.x = ComputeElasticOffset(deltaPointer.x, m_StartPosition.x,
                                                             m_LowBounds.x, m_LowBounds.x - contentViewport.resolvedStyle.width,
                                                             m_HighBounds.x, m_HighBounds.x + contentViewport.resolvedStyle.width);
                    newScrollOffset.y = ComputeElasticOffset(deltaPointer.y, m_StartPosition.y,
                                                             m_LowBounds.y, m_LowBounds.y - contentViewport.resolvedStyle.height,
                                                             m_HighBounds.y, m_HighBounds.y + contentViewport.resolvedStyle.height);
                }
                else
                {
                    newScrollOffset = m_StartPosition - (new Vector2(evt.position.x, evt.position.y) - m_PointerStartPosition);
                }

                if (hasInertia)
                {
                    float deltaTime   = Time.unscaledDeltaTime;
                    var   newVelocity = (newScrollOffset - scrollOffset) / deltaTime;
                    m_Velocity = Vector2.Lerp(m_Velocity, newVelocity, deltaTime * 10);
                }

                scrollOffset = newScrollOffset;

                evt.currentTarget.CapturePointer(evt.pointerId);
                evt.StopPropagation();
            }
        }