コード例 #1
0
        protected virtual void KeyDownCallback(KeyDownEvent e)
        {
            if (e.keyCode == KeyCode.S && e.commandKey)
            {
                SaveGraphToDisk();
                e.StopPropagation();
            }
            else if (nodeViews.Count > 0 && e.commandKey && e.altKey)
            {
                //	Node Aligning shortcuts
                switch (e.keyCode)
                {
                case KeyCode.LeftArrow:
                    nodeViews[0].AlignToLeft();
                    e.StopPropagation();
                    break;

                case KeyCode.RightArrow:
                    nodeViews[0].AlignToRight();
                    e.StopPropagation();
                    break;

                case KeyCode.UpArrow:
                    nodeViews[0].AlignToTop();
                    e.StopPropagation();
                    break;

                case KeyCode.DownArrow:
                    nodeViews[0].AlignToBottom();
                    e.StopPropagation();
                    break;

                case KeyCode.C:
                    nodeViews[0].AlignToCenter();
                    e.StopPropagation();
                    break;

                case KeyCode.M:
                    nodeViews[0].AlignToMiddle();
                    e.StopPropagation();
                    break;
                }
            }
        }
コード例 #2
0
        void OnKeyDown(KeyDownEvent evt)
        {
            if (MouseCaptureController.IsMouseCaptured())
            {
                return;
            }

            if (m_Dictionary.ContainsKey(evt.imguiEvent))
            {
                var result = m_Dictionary[evt.imguiEvent]();
                if (result == EventPropagation.Stop)
                {
                    evt.StopPropagation();
                    if (evt.imguiEvent != null)
                    {
                        evt.imguiEvent.Use();
                    }
                }
            }
        }
コード例 #3
0
 protected void OnKeyDown(KeyDownEvent evt)
 {
     if (m_Active)
     {
         if (evt.keyCode == KeyCode.Escape)
         {
             m_ConnectedEdgeDragHelper.Reset();
             if (m_AdditionalEdgeDragHelpers != null)
             {
                 foreach (var dragHelper in m_AdditionalEdgeDragHelpers)
                 {
                     dragHelper.Reset();
                 }
             }
             Reset();
             target.ReleaseMouse();
             evt.StopPropagation();
         }
     }
 }
コード例 #4
0
        protected void OnKeyDown(KeyDownEvent evt)
        {
            if (m_Active)
            {
                if (evt.keyCode == KeyCode.Escape)
                {
                    RestoreDetachedPort();

                    m_ConnectedEdgeDragHelper.Reset();

                    foreach (var edgeDrag in m_AdditionalEdgeDragHelpers)
                    {
                        edgeDrag.Reset();
                    }

                    Reset();
                    target.ReleaseMouse();
                    evt.StopPropagation();
                }
            }
        }
コード例 #5
0
        private void OnKeyDown(KeyDownEvent e)
        {
            if (e.keyCode != KeyCode.Escape || m_GraphView == null || !m_Active)
            {
                return;
            }

            // Reset the items to their original pos.
            foreach (KeyValuePair <GraphElement, OriginalPos> v in m_OriginalPos)
            {
                OriginalPos originalPos = v.Value;
                if (originalPos.stack != null)
                {
                    originalPos.stack.InsertElement(originalPos.stackIndex, v.Key);
                }
                else
                {
                    v.Key.style.left = originalPos.pos.x;
                    v.Key.style.top  = originalPos.pos.y;
                }
            }

            m_PanSchedule.Pause();

            if (m_ItemPanDiff != Vector3.zero)
            {
                Vector3 p = m_GraphView.contentViewContainer.transform.position;
                Vector3 s = m_GraphView.contentViewContainer.transform.scale;
                m_GraphView.UpdateViewTransform(p, s);
            }

            using (DragExitedEvent dexit = DragExitedEvent.GetPooled())
            {
                List <ISelectable> selection = m_GraphView.selection;
                SendDragAndDropEvent(dexit, selection, m_PrevDropTarget, m_GraphView);
            }

            target.ReleaseMouse();
            e.StopPropagation();
        }
コード例 #6
0
        void OnKeyDown(KeyDownEvent evt)
        {
            IPanel panel = (evt.target as VisualElement)?.panel;

            if (panel.GetCapturingElement(PointerId.mousePointerId) != null)
            {
                return;
            }

            if (m_Dictionary.ContainsKey(evt.imguiEvent))
            {
                var result = m_Dictionary[evt.imguiEvent]();
                if (result == EventPropagation.Stop)
                {
                    evt.StopPropagation();
                    if (evt.imguiEvent != null)
                    {
                        evt.imguiEvent.Use();
                    }
                }
            }
        }
コード例 #7
0
        public void OnKeyDownShortcut(KeyDownEvent evt)
        {
            if (!UIUtils.IsElementVisible(this))
            {
                return;
            }

            // Since the Keyboard Navigation Manipulator only works when the list view is focused, we need to do a special handling
            // when the focus is not on the ListView so that the behaviour is consistent with the scroll view. Note that once the
            // ListView is focused, this function won't trigger because the KeyDownEvent would get intercepted at the ListView level
            // and will not bubble up. Only the arrow keys are supported in the scroll view, so we do the same for ListView for now.
            if ((evt.keyCode == KeyCode.UpArrow && SelectNext(true)) || (evt.keyCode == KeyCode.DownArrow && SelectNext(false)) ||
                (evt.keyCode == KeyCode.A && evt.ctrlKey))
            {
                if (evt.keyCode == KeyCode.A && evt.ctrlKey)
                {
                    SelectAll();
                }
                Focus();
                evt.StopPropagation();
            }
        }
コード例 #8
0
        public void OnKeyDownShortcut(KeyDownEvent evt)
        {
            if (!UIUtils.IsElementVisible(this))
            {
                return;
            }

            if (HandleShiftSelection(evt))
            {
                evt.StopPropagation();
                return;
            }

            if (evt.keyCode == KeyCode.A && evt.actionKey)
            {
                SelectAllVisible();
                evt.StopPropagation();
            }
            else if (evt.keyCode == KeyCode.RightArrow)
            {
                SetSelectedItemExpanded(true);
                evt.StopPropagation();
            }
            else if (evt.keyCode == KeyCode.LeftArrow)
            {
                SetSelectedItemExpanded(false);
                evt.StopPropagation();
            }
            else if (evt.keyCode == KeyCode.UpArrow)
            {
                if (SelectNext(true))
                {
                    evt.StopPropagation();
                }
            }
            else if (evt.keyCode == KeyCode.DownArrow)
            {
                if (SelectNext(false))
                {
                    evt.StopPropagation();
                }
            }
        }
コード例 #9
0
        private void OnKeyDownShortcut(KeyDownEvent evt)
        {
            if (selectedItem == null)
            {
                return;
            }

            if (evt.keyCode == KeyCode.Tab)
            {
                OnFocusChange();
                evt.StopPropagation();
                return;
            }

            if (evt.keyCode == KeyCode.UpArrow)
            {
                if (selectedItem.previousItem != null)
                {
                    Select(selectedItem.previousItem);
                    ScrollIfNeeded();
                }
                else if (selectedItem.packageGroup.previousGroup != null && selectedItem.packageGroup.previousGroup.visible)
                {
                    Select(selectedItem.packageGroup.previousGroup.lastPackage);
                    ScrollIfNeeded();
                }
                evt.StopPropagation();
                return;
            }

            if (evt.keyCode == KeyCode.DownArrow)
            {
                if (selectedItem.nextItem != null)
                {
                    Select(selectedItem.nextItem);
                    ScrollIfNeeded();
                }
                else if (selectedItem.packageGroup.nextGroup != null && selectedItem.packageGroup.nextGroup.visible)
                {
                    Select(selectedItem.packageGroup.nextGroup.firstPackage);
                    ScrollIfNeeded();
                }
                evt.StopPropagation();
                return;
            }

            if (evt.keyCode == KeyCode.PageUp)
            {
                if (selectedItem.packageGroup != null)
                {
                    if (selectedItem == selectedItem.packageGroup.lastPackage && selectedItem != selectedItem.packageGroup.firstPackage)
                    {
                        Select(selectedItem.packageGroup.firstPackage);
                        ScrollIfNeeded();
                    }
                    else if (selectedItem == selectedItem.packageGroup.firstPackage && selectedItem.packageGroup.previousGroup != null && selectedItem.packageGroup.previousGroup.visible)
                    {
                        Select(selectedItem.packageGroup.previousGroup.lastPackage);
                        ScrollIfNeeded();
                    }
                    else if (selectedItem != selectedItem.packageGroup.lastPackage && selectedItem != selectedItem.packageGroup.firstPackage)
                    {
                        Select(selectedItem.packageGroup.firstPackage);
                        ScrollIfNeeded();
                    }
                }
                evt.StopPropagation();
                return;
            }

            if (evt.keyCode == KeyCode.PageDown)
            {
                if (selectedItem.packageGroup != null)
                {
                    if (selectedItem == selectedItem.packageGroup.firstPackage && selectedItem != selectedItem.packageGroup.lastPackage)
                    {
                        Select(selectedItem.packageGroup.lastPackage);
                        ScrollIfNeeded();
                    }
                    else if (selectedItem == selectedItem.packageGroup.lastPackage && selectedItem.packageGroup.nextGroup != null && selectedItem.packageGroup.nextGroup.visible)
                    {
                        Select(selectedItem.packageGroup.nextGroup.firstPackage);
                        ScrollIfNeeded();
                    }
                    else if (selectedItem != selectedItem.packageGroup.firstPackage && selectedItem != selectedItem.packageGroup.lastPackage)
                    {
                        Select(selectedItem.packageGroup.lastPackage);
                        ScrollIfNeeded();
                    }
                }
                evt.StopPropagation();
            }
        }
コード例 #10
0
 void StopKeyPropagation(KeyDownEvent e)
 {
     e.StopPropagation();
 }
コード例 #11
0
        protected virtual void KeyDownCallback(KeyDownEvent e)
        {
            if (EditorWindow.focusedWindow is BaseGraphWindow)
            {
                if (e.keyCode == KeyCode.Z && e.commandKey)
                {
                    //e.StopPropagation();
                }
            }
            if (e.keyCode == KeyCode.S && e.commandKey)
            {
                SaveGraphToDisk();
                e.StopPropagation();
            }
            else if (e.keyCode == KeyCode.Backspace || e.keyCode == KeyCode.Delete)
            {
                var baseStackNodeViewList = new List <BaseStackNodeView>();
                var baseNodeViewList      = new List <BaseNodeView>();
                var groupViewList         = new List <GroupView>();
                var stackCount            = 0;
                var nodeCount             = 0;
                var groupCount            = 0;

                foreach (var selectable in selection)
                {
                    switch (selectable)
                    {
                    case BaseNodeView selectedNodeView:
                        baseNodeViewList.Add(selectedNodeView);
                        nodeCount++;
                        break;

                    case GroupView selectedGroupView:
                        groupViewList.Add(selectedGroupView);
                        groupCount++;
                        break;

                    case BaseStackNodeView baseStackNodeView:
                        baseStackNodeViewList.Add(baseStackNodeView);
                        stackCount++;
                        break;
                    }
                }
                for (var i = 0; i < nodeCount; i++)
                {
                    graph.RemoveNode(baseNodeViewList[i].nodeTarget);
                    var iPortsCount = baseNodeViewList[i].inputPortViews.Count;
                    var oPortsCount = baseNodeViewList[i].outputPortViews.Count;

                    for (var j = 0; j < iPortsCount; j++)
                    {
                        var edgesCopy = baseNodeViewList[i].inputPortViews[j].GetEdges().ToList();
                        foreach (var edge in edgesCopy)
                        {
                            Disconnect(edge);
                        }
                    }

                    for (var j = 0; j < oPortsCount; j++)
                    {
                        var edgesCopy = baseNodeViewList[i].outputPortViews[j].GetEdges().ToList();
                        foreach (var edge in edgesCopy)
                        {
                            Disconnect(edge);
                        }
                    }

                    RemoveNodeView(baseNodeViewList[i]);
                }

                for (var i = 0; i < stackCount; i++)
                {
                    var stackNodeView = baseStackNodeViewList[i];
                    stackNodeView.RemoveAllChildsFromThisStack();
                    // graph.RemoveStackNode(stackNodeView.stackNode);
                    // RemoveStackNodeView(stackNodeView);
                    //ReloadView();
                    //TODO: Remove the stack without removing its nodes.
                }

                for (var i = 0; i < groupCount; i++)
                {
                    var graphElement = groupViewList[i];
                    graphElement.RemoveElementsFromThisGroup();
                    graph.RemoveGroup(graphElement.@group);
                    RemoveElement(graphElement);
                }

                if (nodeCount > 0 || groupCount > 0)
                {
                    e.StopPropagation();
                }
            }
            else if (selection.Count > 0 && e.keyCode == KeyCode.G)
            {
                // var position = new Vector2(100000,100000);
                // var selectedNodeGUIDs = new List<string>();
                // for(var i = 0; i < selection.Count; i++)
                // {
                //  if(!(selection[i] is BaseNodeView)) continue;
                //
                //  var selected = selection[i] as BaseNodeView;
                //
                //  if(selected == null) continue;
                //
                //  var nodeRect                           = selected.GetPosition();
                //  if(nodeRect.x < position.x) position.x = nodeRect.x;
                //  if(nodeRect.y < position.y) position.y = nodeRect.y;
                //
                //  selectedNodeGUIDs.Add(selected.nodeTarget.GUID);
                // }
                // position -= new Vector2(9f,42f);	//	Estimated position
                // var newGroup     = new Group("New Group", position) {innerNodeGUIDs = selectedNodeGUIDs};
                // AddGroup(newGroup);
                // TODO: Uncomment this when groups are stable.
                AddSelectionsToGroup(AddGroup(new Group("New Group", new Vector2(0, 0))));
                e.StopPropagation();
            }
            else if (selection.Count > 0 && e.keyCode == KeyCode.S)
            {
                //	TODO: Uncomment this when stacks are stable.
                // var position = new Vector2(100000,100000);
                // var selectedNodeGUIDs = new List<string>();
                // for(var i = 0; i < selection.Count; i++)
                // {
                //  if(!(selection[i] is BaseNodeView)) continue;
                //
                //  var selected = selection[i] as BaseNodeView;
                //
                //  if(selected == null) continue;
                //
                //  var nodeRect                           = selected.GetPosition();
                //  if(nodeRect.x < position.x) position.x = nodeRect.x;
                //  if(nodeRect.y < position.y) position.y = nodeRect.y;
                //
                //  selectedNodeGUIDs.Add(selected.nodeTarget.GUID);
                // }
                // position -= new Vector2(10f,30f);	//	Estimated position
                // var newStack = new BaseStackNode(position) {nodeGUIDs = selectedNodeGUIDs};
                // AddStackNode(newStack);
                // e.StopPropagation();
            }
            else if (nodeViews.Count > 0 && (e.commandKey || e.ctrlKey) && e.altKey)
            {
                //	Node Aligning shortcuts
                switch (e.keyCode)
                {
                case KeyCode.LeftArrow:
                    nodeViews[0].AlignToLeft();
                    e.StopPropagation();
                    break;

                case KeyCode.RightArrow:
                    nodeViews[0].AlignToRight();
                    e.StopPropagation();
                    break;

                case KeyCode.UpArrow:
                    nodeViews[0].AlignToTop();
                    e.StopPropagation();
                    break;

                case KeyCode.DownArrow:
                    nodeViews[0].AlignToBottom();
                    e.StopPropagation();
                    break;

                case KeyCode.C:
                    nodeViews[0].AlignToCenter();
                    e.StopPropagation();
                    break;

                case KeyCode.M:
                    nodeViews[0].AlignToMiddle();
                    e.StopPropagation();
                    break;
                }
            }
        }
コード例 #12
0
        private void OnKeyDownShortcut(KeyDownEvent evt)
        {
            if (selectedItem == null)
            {
                return;
            }

            if (evt.keyCode == KeyCode.Tab)
            {
                OnFocusChange();
                evt.StopPropagation();
                return;
            }

            if (evt.keyCode == KeyCode.UpArrow)
            {
                var nextVisibleItem = FindNextVisiblePackageItem(selectedItem, true);
                if (nextVisibleItem != null)
                {
                    Select(nextVisibleItem);
                    ScrollIfNeeded();
                }
                evt.StopPropagation();
                return;
            }

            if (evt.keyCode == KeyCode.DownArrow)
            {
                var nextVisibleItem = FindNextVisiblePackageItem(selectedItem, false);
                if (nextVisibleItem != null)
                {
                    Select(nextVisibleItem);
                    ScrollIfNeeded();
                }
                evt.StopPropagation();
                return;
            }

            if (evt.keyCode == KeyCode.PageUp)
            {
                var targetItem = FindPackageItemPageUpOrPageDown(selectedItem, true);
                if (targetItem != null)
                {
                    Select(targetItem);
                    ScrollIfNeeded();
                }
                evt.StopPropagation();
                return;
            }

            if (evt.keyCode == KeyCode.PageDown)
            {
                var targetItem = FindPackageItemPageUpOrPageDown(selectedItem, false);
                if (targetItem != null)
                {
                    Select(targetItem);
                    ScrollIfNeeded();
                }
                evt.StopPropagation();
                return;
            }
        }
コード例 #13
0
        void OnKeyDown(KeyDownEvent evt)
        {
            if (!textInputField.hasFocus)
            {
                return;
            }

            textInputField.SyncTextEngine();
            m_Changed = false;

            // Check for action keys.
            if (editorEngine.HandleKeyEvent(evt.imguiEvent))
            {
                if (textInputField.text != editorEngine.text)
                {
                    m_Changed = true;
                }
                evt.StopPropagation();
            }
            else
            {
                // Ignore tab & shift-tab in text fields
                if (evt.keyCode == KeyCode.Tab || evt.character == '\t')
                {
                    return;
                }

                evt.StopPropagation();

                char c = evt.character;

                if (c == '\n' && !editorEngine.multiline && !evt.altKey)
                {
                    return;
                }

                if (!textInputField.AcceptCharacter(c))
                {
                    return;
                }

                // Simplest test: only allow the character if the display font supports it.
                Font font = editorEngine.style.font;
                if (font != null && font.HasCharacter(c) || c == '\n')
                {
                    // Input event
                    editorEngine.Insert(c);
                    m_Changed = true;
                }
                // On windows, key presses also send events with keycode but no character. Eat them up here.
                else if (c == 0)
                {
                    // if we have a composition string, make sure we clear the previous selection.
                    if (!string.IsNullOrEmpty(Input.compositionString))
                    {
                        editorEngine.ReplaceSelection("");
                        m_Changed = true;
                    }
                }
            }

            if (m_Changed)
            {
                editorEngine.text = textInputField.CullString(editorEngine.text);
                textInputField.UpdateText(editorEngine.text);
            }

            // Scroll offset might need to be updated
            editorEngine.UpdateScrollOffset();
        }
コード例 #14
0
        private void OnKeyDownShortcut(KeyDownEvent evt)
        {
            if (selectedItem == null)
            {
                return;
            }

            if (evt.keyCode == KeyCode.UpArrow)
            {
                if (selectedItem.previousItem != null)
                {
                    Select(selectedItem.previousItem);
                    ScrollIfNeeded();
                }
                else if (selectedItem.packageGroup != null && selectedItem.packageGroup.previousGroup != null)
                {
                    selectedItem.packageGroup.previousGroup.SetCollapsed(false);
                    Select(selectedItem.packageGroup.previousGroup.lastPackage);
                    ScrollIfNeeded();
                }
                evt.StopPropagation();
                return;
            }

            if (evt.keyCode == KeyCode.DownArrow)
            {
                if (selectedItem.nextItem != null)
                {
                    Select(selectedItem.nextItem);
                    ScrollIfNeeded();
                }
                else if (selectedItem.packageGroup != null && selectedItem.packageGroup.nextGroup != null)
                {
                    selectedItem.packageGroup.nextGroup.SetCollapsed(false);
                    Select(selectedItem.packageGroup.nextGroup.firstPackage);
                    ScrollIfNeeded();
                }
                evt.StopPropagation();
                return;
            }

#if UNITY_2018_2_OR_NEWER
            if (evt.keyCode == KeyCode.LeftArrow)
            {
                if (selectedItem.packageGroup != null)
                {
                    if (!selectedItem.packageGroup.Collapsed)
                    {
                        selectedItem.packageGroup.SetCollapsed(true);
                        if (selectedItem.packageGroup.nextGroup != null)
                        {
                            selectedItem.packageGroup.nextGroup.SetCollapsed(false);
                            Select(selectedItem.packageGroup.nextGroup.firstPackage);
                            ScrollIfNeeded();
                        }
                        else if (selectedItem.packageGroup.previousGroup != null)
                        {
                            selectedItem.packageGroup.previousGroup.SetCollapsed(false);
                            Select(selectedItem.packageGroup.previousGroup.lastPackage);
                            ScrollIfNeeded();
                        }
                    }
                }
                evt.StopPropagation();
                return;
            }
#endif

            if (evt.keyCode == KeyCode.PageUp)
            {
                if (selectedItem.packageGroup != null)
                {
                    if (selectedItem == selectedItem.packageGroup.lastPackage && selectedItem != selectedItem.packageGroup.firstPackage)
                    {
                        Select(selectedItem.packageGroup.firstPackage);
                        ScrollIfNeeded();
                    }
                    else if (selectedItem == selectedItem.packageGroup.firstPackage && selectedItem.packageGroup.previousGroup != null)
                    {
                        if (selectedItem.packageGroup.previousGroup.Collapsed)
                        {
                            selectedItem.packageGroup.previousGroup.SetCollapsed(false);
                        }

                        Select(selectedItem.packageGroup.previousGroup.lastPackage);
                        ScrollIfNeeded();
                    }
                    else if (selectedItem != selectedItem.packageGroup.lastPackage && selectedItem != selectedItem.packageGroup.firstPackage)
                    {
                        Select(selectedItem.packageGroup.firstPackage);
                        ScrollIfNeeded();
                    }
                }
                evt.StopPropagation();
                return;
            }

            if (evt.keyCode == KeyCode.PageDown)
            {
                if (selectedItem.packageGroup != null)
                {
                    if (selectedItem == selectedItem.packageGroup.firstPackage && selectedItem != selectedItem.packageGroup.lastPackage)
                    {
                        Select(selectedItem.packageGroup.lastPackage);
                        ScrollIfNeeded();
                    }
                    else if (selectedItem == selectedItem.packageGroup.lastPackage && selectedItem.packageGroup.nextGroup != null)
                    {
                        if (selectedItem.packageGroup.nextGroup.Collapsed)
                        {
                            selectedItem.packageGroup.nextGroup.SetCollapsed(false);
                        }

                        Select(selectedItem.packageGroup.nextGroup.firstPackage);
                        ScrollIfNeeded();
                    }
                    else if (selectedItem != selectedItem.packageGroup.firstPackage && selectedItem != selectedItem.packageGroup.lastPackage)
                    {
                        Select(selectedItem.packageGroup.lastPackage);
                        ScrollIfNeeded();
                    }
                }
                evt.StopPropagation();
            }
        }