Esempio n. 1
0
        private void BeginDrag()
        {
            if (currentDragEvent != null)
            {
                return;
            }

            if (m_MouseDownElements.size == 0)
            {
                return;
            }

            mouseState.leftMouseButtonState.isDrag   = mouseState.isLeftMouseDown;
            mouseState.rightMouseButtonState.isDrag  = mouseState.isRightMouseDown;
            mouseState.middleMouseButtonState.isDrag = mouseState.isMiddleMouseDown;

            IsDragging = true;
            m_EventPropagator.Reset(mouseState);

            m_EventPropagator.origin = m_MouseDownElements.array[0];

            for (int i = 0; i < m_MouseDownElements.Count; i++)
            {
                UIElement element = m_MouseDownElements[i];

                if (element.isDestroyed || element.isDisabled || element.inputHandlers == null)
                {
                    continue;
                }

                if ((element.inputHandlers.handledEvents & InputEventType.DragCreate) == 0)
                {
                    continue;
                }

                for (int creatorIndex = 0; creatorIndex < element.inputHandlers.dragCreators.size; creatorIndex++)
                {
                    InputHandlerGroup.DragCreatorData data = element.inputHandlers.dragCreators.array[creatorIndex];

                    currentDragEvent = data.handler.Invoke(new MouseInputEvent(m_EventPropagator, InputEventType.DragCreate, m_KeyboardState.modifiersThisFrame, false, element));

                    if (currentDragEvent != null)
                    {
                        currentDragEvent.StartTime         = Time.realtimeSinceStartup;
                        currentDragEvent.DragStartPosition = MousePosition;
                        currentDragEvent.origin            = element;
                        currentDragEvent.Begin();
                        UpdateDrag(true);
                        return;
                    }
                }
            }

            if (currentDragEvent == null)
            {
                IsDragging = false;
            }

            // todo -- capture phase
        }