Esempio n. 1
0
        protected void OnMouseDown(MouseDownEvent e)
        {
            if (m_Active)
            {
                e.StopImmediatePropagation();
                return;
            }

            m_Active           = false;
            m_Dragging         = false;
            m_AddedByMouseDown = false;

            if (target == null)
            {
                return;
            }

            selectionContainer = target.GetFirstAncestorOfType <ISelection>();

            if (selectionContainer == null)
            {
                return;
            }

            selectedElement = target.GetFirstOfType <GraphElement>();

            if (selectedElement == null)
            {
                return;
            }

            // Since we didn't drag after all, update selection with current element only
            if (!selectionContainer.selection.Contains(selectedElement))
            {
                if (!e.ctrlKey)
                {
                    selectionContainer.ClearSelection();
                }
                selectionContainer.AddToSelection(selectedElement);
                m_AddedByMouseDown = true;
            }

            if (e.button == (int)activateButton)
            {
                // avoid starting a manipulation on a non movable object

                if (!selectedElement.IsDroppable())
                {
                    return;
                }

                // Reset drag and drop
                m_DragAndDropDelay.Init(e.localMousePosition);

                m_Active = true;
                target.TakeMouseCapture();
                e.StopPropagation();
            }
        }