Ejemplo n.º 1
0
        void OnMouseDown(MouseDownEvent e)
        {
            if (active)
            {
                e.StopPropagation();
                return;
            }

            if (MouseCaptureController.IsMouseCaptured())
            {
                return;
            }

            if (!IsMouseOverBorders(e.localMousePosition))
            {
                return;
            }

            if (CanStartManipulation(e))
            {
                active = true;
                target.CaptureMouse();
                e.StopPropagation();

                startComponentSize     = new Vector2(elem.style.width, elem.style.height);
                startMousePosition     = e.localMousePosition;
                startComponentPosition = elem.transform.position;
            }
            else
            {
                Debug.Log("can't start manipulation !");
            }
        }
Ejemplo n.º 2
0
        void OnMouseDown(MouseDownEvent evt)
        {
            textInputField.SyncTextEngine();
            m_Changed = false;

            if (!textInputField.hasFocus)
            {
                editorEngine.m_HasFocus = true;

                editorEngine.MoveCursorToPosition_Internal(evt.localMousePosition, evt.button == (int)MouseButton.LeftMouse && evt.shiftKey);

                if (evt.button == (int)MouseButton.LeftMouse)
                {
                    textInputField.TakeMouseCapture();
                }

                evt.StopPropagation();
            }
            else if (evt.button == (int)MouseButton.LeftMouse)
            {
                if (evt.clickCount == 2 && textInputField.doubleClickSelectsWord)
                {
                    editorEngine.SelectCurrentWord();
                    editorEngine.DblClickSnap(TextEditor.DblClickSnapping.WORDS);
                    editorEngine.MouseDragSelectsWholeWords(true);
                    m_DragToPosition = false;
                }
                else if (evt.clickCount == 3 && textInputField.tripleClickSelectsLine)
                {
                    editorEngine.SelectCurrentParagraph();
                    editorEngine.MouseDragSelectsWholeWords(true);
                    editorEngine.DblClickSnap(TextEditor.DblClickSnapping.PARAGRAPHS);
                    m_DragToPosition = false;
                }
                else
                {
                    editorEngine.MoveCursorToPosition_Internal(evt.localMousePosition, evt.shiftKey);
                    m_SelectAllOnMouseUp = false;
                }

                textInputField.TakeMouseCapture();
                evt.StopPropagation();
            }
            else if (evt.button == (int)MouseButton.RightMouse)
            {
                if (editorEngine.cursorIndex == editorEngine.selectIndex)
                {
                    editorEngine.MoveCursorToPosition_Internal(evt.localMousePosition, false);
                }
                m_SelectAllOnMouseUp = false;
                m_DragToPosition     = false;
            }

            // Scroll offset might need to be updated
            editorEngine.UpdateScrollOffset();
        }
Ejemplo n.º 3
0
 private void OnMouseDown(MouseDownEvent evt)
 {
     base.textInputField.SyncTextEngine();
     this.m_Changed = false;
     if (!base.textInputField.hasFocus)
     {
         base.editorEngine.m_HasFocus = true;
         base.editorEngine.MoveCursorToPosition_Internal(evt.localMousePosition, evt.button == 0 && evt.shiftKey);
         if (evt.button == 0)
         {
             base.textInputField.TakeMouseCapture();
         }
         evt.StopPropagation();
     }
     else if (evt.button == 0)
     {
         if (evt.clickCount == 2 && base.textInputField.doubleClickSelectsWord)
         {
             base.editorEngine.SelectCurrentWord();
             base.editorEngine.DblClickSnap(TextEditor.DblClickSnapping.WORDS);
             base.editorEngine.MouseDragSelectsWholeWords(true);
             this.m_DragToPosition = false;
         }
         else if (evt.clickCount == 3 && base.textInputField.tripleClickSelectsLine)
         {
             base.editorEngine.SelectCurrentParagraph();
             base.editorEngine.MouseDragSelectsWholeWords(true);
             base.editorEngine.DblClickSnap(TextEditor.DblClickSnapping.PARAGRAPHS);
             this.m_DragToPosition = false;
         }
         else
         {
             base.editorEngine.MoveCursorToPosition_Internal(evt.localMousePosition, evt.shiftKey);
             this.m_SelectAllOnMouseUp = false;
         }
         base.textInputField.TakeMouseCapture();
         evt.StopPropagation();
     }
     else if (evt.button == 1)
     {
         if (base.editorEngine.cursorIndex == base.editorEngine.selectIndex)
         {
             base.editorEngine.MoveCursorToPosition_Internal(evt.localMousePosition, false);
         }
         this.m_SelectAllOnMouseUp = false;
         this.m_DragToPosition     = false;
     }
     base.editorEngine.UpdateScrollOffset();
 }
Ejemplo n.º 4
0
 private void OnMouseDown(MouseDownEvent e)
 {
     if (this.m_Active)
     {
         e.StopImmediatePropagation();
     }
     else
     {
         GraphView graphView = base.target as GraphView;
         if (graphView != null)
         {
             if (base.CanStartManipulation(e))
             {
                 if (!e.shiftKey)
                 {
                     graphView.ClearSelection();
                 }
                 graphView.Add(this.m_Rectangle);
                 this.m_Rectangle.start = e.localMousePosition;
                 this.m_Rectangle.end   = this.m_Rectangle.start;
                 this.m_Active          = true;
                 base.target.TakeMouseCapture();
                 e.StopPropagation();
             }
         }
     }
 }
        private void OnMouseDown(MouseDownEvent e)
        {
            if (m_Active)
            {
                e.StopImmediatePropagation();
                return;
            }

            if (e.target != target)
            {
                return;
            }

            if (CanStartManipulation(e))
            {
                m_GraphView.ClearSelection();

                m_GraphView.Add(m_FreehandElement);

                m_FreehandElement.points.Clear();
                m_FreehandElement.points.Add(e.localMousePosition);
                m_FreehandElement.deleteModifier = e.shiftKey;

                m_Active = true;
                target.TakeMouseCapture();
                e.StopPropagation();
            }
        }
Ejemplo n.º 6
0
            protected void OnMouseDown(MouseDownEvent e)
            {
                if (m_Active)
                {
                    e.StopImmediatePropagation();
                    return;
                }

                if (CanStartManipulation(e))
                {
                    // Ignore double-click to allow text editing of the selected element
                    if (e.clickCount == 2)
                    {
                        return;
                    }

                    m_StartDrag(target);
                    m_Start = e.mousePosition;

                    m_Active = true;
                    target.CaptureMouse();
                    e.StopPropagation();

                    target.AddToClassList(s_ActiveHandleClassName);
                }
            }
        void OnMouseDown(MouseDownEvent evt)
        {
            if (m_Active)
            {
                evt.StopImmediatePropagation();
                return;
            }

            if (m_ParameterElement.ConfigEditor.FilterString != string.Empty)
            {
                return;
            }

            m_ParameterContainer  = target.parent;
            m_DragBar             = new ParameterDragBar();
            m_DragBar.style.width = new StyleLength(m_ParameterContainer.resolvedStyle.width);
            target.parent.Add(m_DragBar);

            m_Offset            = m_DragHandle.worldBound.position.y - m_ParameterContainer.worldBound.position.y;
            m_DragBar.style.top = evt.localMousePosition.y + m_Offset;

            m_Active = true;
            m_DragHandle.CaptureMouse();
            evt.StopPropagation();
        }
Ejemplo n.º 8
0
 private void EatMouseDown(MouseDownEvent e)
 {
     if (e.button == 0 && (capabilities & Capabilities.Movable) == 0)
     {
         e.StopPropagation();
     }
 }
Ejemplo n.º 9
0
        protected void OnMouseDown(MouseDownEvent evt)
        {
            if (CanStartManipulation(evt))
            {
                target.TakeMouseCapture();
                lastMousePosition = evt.localMousePosition;

                if (IsRepeatable())
                {
                    // Repeatable button clicks are performed on the MouseDown and at timer events
                    if (clicked != null && target.ContainsPoint(evt.localMousePosition))
                    {
                        clicked();
                    }

                    if (m_Repeater == null)
                    {
                        m_Repeater = target.schedule.Execute(OnTimer).Every(m_Interval).StartingIn(m_Delay);
                    }
                    else
                    {
                        m_Repeater.ExecuteLater(m_Delay);
                    }
                }

                target.pseudoStates |= PseudoStates.Active;

                evt.StopPropagation();
            }
        }
        void PickCurrentHoveredElement(VisualElement element, MouseDownEvent evt, SerializedProperty property)
        {
            // Prefer picking something distinguishable with a name specified.
            if (element.name.IsNullOrEmpty())
            {
                const int numParentsToSearch = 10;
                // Try going up in the hierachy until one with a name is found
                var elem = element;
                for (int i = 0; i < numParentsToSearch; i++)
                {
                    if (elem == null)
                    {
                        break;
                    }

                    if (!elem.name.IsNullOrEmpty())
                    {
                        element = elem;
                        break;
                    }

                    elem = element.parent;
                }
            }

            property.FindPropertyRelative(k_VisualElementNamePath).stringValue      = element.name;
            property.FindPropertyRelative(k_VisualElementClassNamePath).stringValue = element.GetClasses().LastOrDefault()?.ToString();
            property.FindPropertyRelative(k_VisualElementTypeNamePath).stringValue  = element.GetType().ToString();
            // Apply modifications before serializedObject.Update(); call in TutorialPageEditor would dismiss them.
            property.serializedObject.ApplyModifiedProperties();

            evt.StopPropagation();

            EndPicking();
        }
Ejemplo n.º 11
0
        protected void OnMouseDown(MouseDownEvent evt)
        {
            if (m_Active)
            {
                evt.StopImmediatePropagation();
                return;
            }

            if (!CanStartManipulation(evt))
            {
                return;
            }

            m_Edge = (evt.target as VisualElement).parent as Edge;

            if (m_Edge != null)
            {
                m_EdgePresenter = m_Edge.GetPresenter <EdgePresenter>();
            }

            m_PressPos = evt.mousePosition;
            target.TakeMouseCapture();
            evt.StopPropagation();
            m_LastMouseDownEvent = evt;
        }
Ejemplo n.º 12
0
        private void OnMouseDown(MouseDownEvent e)
        {
            var gView = graphView;

            // Refresh MiniMap rects
            CalculateRects(gView.contentViewContainer);

            var mousePosition = e.localMousePosition;

            gView.graphElements.ForEach(child =>
            {
                if (child == null)
                {
                    return;
                }
                var selectable = child.GetFirstOfType <ISelectable>();
                if (selectable == null || !selectable.IsSelectable())
                {
                    return;
                }

                if (CalculateElementRect(child).Contains(mousePosition))
                {
                    gView.ClearSelection();
                    gView.AddToSelection(selectable);
                    gView.FrameSelection();
                    e.StopPropagation();
                }
            });

            EatMouseDown(e);
        }
Ejemplo n.º 13
0
 protected void OnMouseDown(MouseDownEvent evt)
 {
     if (base.CanStartManipulation(evt))
     {
         base.target.TakeMouseCapture();
         this.lastMousePosition = evt.localMousePosition;
         if (this.IsRepeatable())
         {
             if (this.clicked != null && base.target.ContainsPoint(evt.localMousePosition))
             {
                 this.clicked();
             }
             if (this.m_Repeater == null)
             {
                 this.m_Repeater = base.target.schedule.Execute(new Action <TimerState>(this.OnTimer)).Every(this.m_Interval).StartingIn(this.m_Delay);
             }
             else
             {
                 this.m_Repeater.ExecuteLater(this.m_Delay);
             }
         }
         base.target.pseudoStates |= PseudoStates.Active;
         evt.StopPropagation();
     }
 }
Ejemplo n.º 14
0
 void OnMouseDown(MouseDownEvent e)
 {
     if (e.button != (int)MouseButton.LeftMouse)
     {
         e.StopPropagation();
     }
 }
Ejemplo n.º 15
0
 private void OnMouseDown(MouseDownEvent e)
 {
     if (this.m_Active)
     {
         e.StopImmediatePropagation();
     }
     else if (!MouseCaptureController.IsMouseCaptureTaken())
     {
         GraphElement graphElement = base.parent as GraphElement;
         if (graphElement != null)
         {
             if (graphElement.IsResizable())
             {
                 if (e.button == (int)this.activateButton)
                 {
                     this.m_Start    = this.ChangeCoordinatesTo(base.parent, e.localMousePosition);
                     this.m_StartPos = base.parent.layout;
                     if (base.parent.style.positionType != PositionType.Manual)
                     {
                         Debug.LogWarning("Attempting to resize an object with a non manual position");
                     }
                     this.m_Active = true;
                     this.TakeMouseCapture();
                     e.StopPropagation();
                 }
             }
         }
     }
 }
Ejemplo n.º 16
0
        private void OnMouseDown(MouseDownEvent e)
        {
            if (m_Active)
            {
                e.StopImmediatePropagation();
                return;
            }

            var graphView = target as GraphView;

            if (graphView == null)
            {
                return;
            }

            if (CanStartManipulation(e))
            {
                if (!e.shiftKey)
                {
                    graphView.ClearSelection();
                }

                graphView.Add(m_Rectangle);

                m_Rectangle.start = e.localMousePosition;
                m_Rectangle.end   = m_Rectangle.start;

                m_Active = true;
                target.TakeMouseCapture(); // We want to receive events even when mouse is not over ourself.
                e.StopPropagation();
            }
        }
Ejemplo n.º 17
0
        void OnMouseDown(MouseDownEvent e)
        {
            if (e.button == 0 && e.clickCount == 1)
            {
                VisualElement resizedTarget = resizedElement.parent;
                if (resizedTarget != null)
                {
                    VisualElement resizedBase = resizedTarget.parent;
                    if (resizedBase != null)
                    {
                        target.RegisterCallback <MouseMoveEvent>(OnMouseMove);
                        e.StopPropagation();
                        target.CaptureMouse();
                        m_StartMouse    = resizedBase.WorldToLocal(e.mousePosition);
                        m_StartSize     = new Vector2(resizedTarget.resolvedStyle.width, resizedTarget.resolvedStyle.height);
                        m_StartPosition = new Vector2(resizedTarget.resolvedStyle.left, resizedTarget.resolvedStyle.top);

                        bool minWidthDefined  = resizedTarget.resolvedStyle.minWidth != StyleKeyword.Auto;
                        bool maxWidthDefined  = resizedTarget.resolvedStyle.maxWidth != StyleKeyword.None;
                        bool minHeightDefined = resizedTarget.resolvedStyle.minHeight != StyleKeyword.Auto;
                        bool maxHeightDefined = resizedTarget.resolvedStyle.maxHeight != StyleKeyword.None;
                        m_MinSize = new Vector2(
                            minWidthDefined ? resizedTarget.resolvedStyle.minWidth.value : Mathf.NegativeInfinity,
                            minHeightDefined ? resizedTarget.resolvedStyle.minHeight.value : Mathf.NegativeInfinity);
                        m_MaxSize = new Vector2(
                            maxWidthDefined ? resizedTarget.resolvedStyle.maxWidth.value : Mathf.Infinity,
                            maxHeightDefined ? resizedTarget.resolvedStyle.maxHeight.value : Mathf.Infinity);

                        m_DragStarted = false;
                    }
                }
            }
        }
Ejemplo n.º 18
0
        private void OnMouseDown(MouseDownEvent e)
        {
            if (e.button != 0)
            {
                return;
            }
            GraphView gView = graphView;

            CalculateRects(gView.contentViewContainer);
            Vector2 mousePosition = e.localMousePosition;

            gView.graphElements.ForEach(delegate(GraphElement child) {
                if (child != null)
                {
                    ISelectable firstOfType = child.GetFirstOfType <ISelectable>();
                    if (firstOfType != null && firstOfType.IsSelectable() && CalculateElementRect(child).Contains(mousePosition))
                    {
                        gView.ClearSelection();
                        gView.AddToSelection(firstOfType);
                        gView.FrameSelection();
                        e.StopPropagation();
                    }
                }
            });
            EatMouseDown(e);
        }
Ejemplo n.º 19
0
        protected void OnMouseDown(MouseDownEvent e)
        {
            if (m_Active)
            {
                e.StopImmediatePropagation();
                return;
            }

            /*
             * IDraggable ce = e.target as IDraggable;
             * if (ce == null || !ce.IsMovableNow())
             * {
             *  return;
             * }
             */

            if (CanStartManipulation(e))
            {
                m_Start = e.localMousePosition;

                m_Active = true;
                target.CaptureMouse();
                e.StopPropagation();
            }
        }
Ejemplo n.º 20
0
        protected void OnMouseDown(MouseDownEvent e)
        {
            if (m_Active)
            {
                e.StopImmediatePropagation();
                return;
            }

            if (!CanStartManipulation(e))
            {
                return;
            }

            var graphView = target as GraphView;

            if (graphView == null)
            {
                return;
            }

            m_Start = graphView.ChangeCoordinatesTo(graphView.contentViewContainer, e.localMousePosition);

            m_Active = true;
            target.TakeMouseCapture();
            e.StopPropagation();
        }
Ejemplo n.º 21
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();
            }
        }
Ejemplo n.º 22
0
 protected void OnMouseDown(MouseDownEvent evt)
 {
     if (clicked != null)
     {
         clicked();
         evt.StopPropagation();
     }
 }
Ejemplo n.º 23
0
        void OnMouseDown(MouseDownEvent evt)
        {
            m_Active           = true;
            m_LocalMosueOffset = target.WorldToLocal(evt.mousePosition);

            target.TakeMouseCapture();
            evt.StopPropagation();
        }
Ejemplo n.º 24
0
 private void OnMouseUpDownEvent(MouseDownEvent evt)
 {
     base.SyncTextEditor();
     base.textField.TakeCapture();
     this.keyboardOnScreen = TouchScreenKeyboard.Open(string.IsNullOrEmpty(this.secureText) ? base.textField.text : this.secureText, TouchScreenKeyboardType.Default, true, this.multiline, !string.IsNullOrEmpty(this.secureText));
     base.UpdateScrollOffset();
     evt.StopPropagation();
 }
Ejemplo n.º 25
0
 private void OnMouseDown(MouseDownEvent evt)
 {
     base.SyncTextEditor();
     this.m_Changed = false;
     base.target.TakeCapture();
     if (!this.m_HasFocus)
     {
         this.m_HasFocus = true;
         base.MoveCursorToPosition_Internal(evt.localMousePosition, evt.shiftKey);
         evt.StopPropagation();
     }
     else
     {
         if (evt.clickCount == 2 && base.doubleClickSelectsWord)
         {
             base.SelectCurrentWord();
             base.DblClickSnap(TextEditor.DblClickSnapping.WORDS);
             base.MouseDragSelectsWholeWords(true);
             this.m_DragToPosition = false;
         }
         else if (evt.clickCount == 3 && base.tripleClickSelectsLine)
         {
             base.SelectCurrentParagraph();
             base.MouseDragSelectsWholeWords(true);
             base.DblClickSnap(TextEditor.DblClickSnapping.PARAGRAPHS);
             this.m_DragToPosition = false;
         }
         else
         {
             base.MoveCursorToPosition_Internal(evt.localMousePosition, evt.shiftKey);
             this.m_SelectAllOnMouseUp = false;
         }
         evt.StopPropagation();
     }
     if (this.m_Changed)
     {
         if (base.maxLength >= 0 && base.text != null && base.text.Length > base.maxLength)
         {
             base.text = base.text.Substring(0, base.maxLength);
         }
         base.textField.text = base.text;
         base.textField.TextFieldChanged();
         evt.StopPropagation();
     }
     base.UpdateScrollOffset();
 }
Ejemplo n.º 26
0
 void OnMouseDown(MouseDownEvent e)
 {
     m_Dragging = true;
     EditorGUIUtility.SetWantsMouseJumping(1);
     target.TakeMouseCapture();
     target.RegisterCallback <MouseMoveEvent>(OnMouseMove, Capture.Capture);
     m_Dragging = true;
     e.StopPropagation();
 }
Ejemplo n.º 27
0
 private void OnMouseDown(MouseDownEvent MouseDownEvent)
 {
     Selection.activeGameObject = ObjectReference;
     if (OnInteractiveObjectFieldClicked != null)
     {
         OnInteractiveObjectFieldClicked.Invoke(MouseDownEvent, this);
     }
     MouseDownEvent.StopPropagation();
 }
Ejemplo n.º 28
0
 private void EatMouseDown(MouseDownEvent e)
 {
     // The minimap should not let any left mouse down go through when it's not movable.
     if (e.button == (int)MouseButton.LeftMouse &&
         (capabilities & Capabilities.Movable) == 0)
     {
         e.StopPropagation();
     }
 }
Ejemplo n.º 29
0
 void OnTitleMouseDown(MouseDownEvent e)
 {
     if (e.clickCount == 2)
     {
         OnRename();
         e.StopPropagation();
         e.PreventDefault();
     }
 }
        /// <summary>
        /// Callback for the MouseDown event.
        /// </summary>
        /// <param name="e">The event.</param>
        protected void OnMouseDown(MouseDownEvent e)
        {
            if (m_Active)
            {
                e.StopImmediatePropagation();
                return;
            }

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

            if (target == null)
            {
                return;
            }

            m_SelectionContainer = target.GetFirstAncestorOfType <IDragSource>();

            if (m_SelectionContainer == null)
            {
                // Keep for potential later use in OnMouseUp (where e.target might be different then)
                m_SelectionContainer = target.GetFirstOfType <IDragSource>();
                m_SelectedElement    = e.target as GraphElement;
                return;
            }

            m_SelectedElement = target.GetFirstOfType <GraphElement>();

            if (m_SelectedElement == null)
            {
                return;
            }

            // Since we didn't drag after all, update selection with current element only
            if (!m_SelectedElement.IsSelected())
            {
                var selectionMode = e.actionKey ? SelectElementsCommand.SelectionMode.Add : SelectElementsCommand.SelectionMode.Replace;
                m_SelectedElement.CommandDispatcher.Dispatch(new SelectElementsCommand(selectionMode, m_SelectedElement.Model));
                m_AddedByMouseDown = true;
            }

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

                if (!m_SelectedElement.Model.IsDroppable())
                {
                    return;
                }

                m_MouseDownPosition = e.localMousePosition;
                m_Active            = true;
                target.CaptureMouse();
                e.StopPropagation();
            }
        }