Esempio n. 1
0
        /// <summary>
        /// Handles sending the motion data to the selected nodes
        /// </summary>
        private void HandleMouseMove()
        {
            IEnumerable <Node> selectedNodes = NodeEditor.GetSelectedNodes();

            int used  = 0;
            int count = 0;

            Vector2 zoomedDrag = NodeEditor.ApplyZoomToVector(Event.current.delta);

            foreach (Node node in selectedNodes)
            {
                if (node.HandleDrag(zoomedDrag))
                {
                    used++;
                }
                count++;
            }

            if (used > 0)
            {
                NodeEditor.FlagRepaint();
                Event.current.Use();
            }
            else if (count == 0)
            {
                Deactivate();
            }
        }
        /// <summary>
        /// Configures the rectangle used for selection
        /// </summary>
        public override void AfterEditorEvents()
        {
            CheckActivation();

            if (!IsActivated)
            {
                return;
            }

            if (Event.current.button != 0)
            {
                Cancel();
                Event.current.Use();
                return;
            }

            if (Event.current.type == EventType.MouseDrag)
            {
                Vector2 startPoint = NodeEditor.ApplyZoomToVector(dragStartPos);
                Vector2 endPoint   = NodeEditor.GetZoomedMousePosition();

                selectionRect = RectExtensions.FromPoints(startPoint, endPoint);

                NodeEditor.FlagRepaint();
                Event.current.Use();
            }
            else if (Event.current.type == EventType.MouseUp)
            {
                SelectNodes();
                SelectConnectors();

                NodeEditor.RaiseSelectionChanged();

                selectionRect = Rect.zero;
                Deactivate();

                Event.current.Use();
            }
            else if (Event.current.type == EventType.MouseLeaveWindow)
            {
                Cancel();
            }
        }