示例#1
0
        private void MonitorKeys(KeyDownEvent evt)
        {
            void ShowResearcher()
            {
                var insertViewIndex = linesContainer.childCount;
                var insertIndex     = ViewToGlobaIndex(insertViewIndex);

                ShowSearcher(Event.current.mousePosition, insertIndex, insertViewIndex);
            }

            if (evt != null)
            {
                if (evt.keyCode == config.InsertLineKey && (evt.modifiers & config.InsertLineModifier) != 0)
                {
                    ShowResearcher();
                }
                else if (evt.keyCode == config.SaveScriptKey && (evt.modifiers & config.SaveScriptModifier) != 0)
                {
                    saveAssetAction?.Invoke();
                }
                evt.StopImmediatePropagation();
            }
            else if (Event.current != null && Event.current.type == EventType.KeyDown)
            {
                if (Event.current.keyCode == config.InsertLineKey && Event.current.modifiers == config.InsertLineModifier)
                {
                    ShowResearcher();
                }
                else if (Event.current.keyCode == config.SaveScriptKey && Event.current.modifiers == config.SaveScriptModifier)
                {
                    saveAssetAction?.Invoke();
                }
            }
        }
示例#2
0
        private void OnKeyDownShortcut(KeyDownEvent evt)
        {
            if (evt.keyCode == KeyCode.Escape)
            {
                SearchCancelButtonClick();
                SearchCancelButton.Focus();
                evt.StopImmediatePropagation();
                return;
            }

            if (evt.keyCode == KeyCode.Tab)
            {
                OnFocusChange();
                evt.StopImmediatePropagation();
            }
        }
        void OnEnterStyleSelectorNameChange(KeyDownEvent evt)
        {
            if (evt.keyCode != KeyCode.Return && evt.keyCode != KeyCode.KeypadEnter)
            {
                return;
            }

            if (m_Selection.selectionType != BuilderSelectionType.StyleSelector)
            {
                return;
            }

            if (m_TextField.text.Length == 0)
            {
                Refresh();
                return;
            }

            if (m_TextField.text == currentVisualElement.name)
            {
                return;
            }

            ValidateStyleSelectorNameChange(m_TextField.text);

            evt.PreventDefault();
            evt.StopImmediatePropagation();
        }
示例#4
0
 // The default ListView escape key behaviour is to clear all selections, however, we want to always have something selected
 // therefore we register a TrickleDown callback handler to intercept escape key events to make it do nothing.
 private void IgnoreEscapeKeyDown(KeyDownEvent evt)
 {
     if (evt.keyCode == KeyCode.Escape)
     {
         evt.StopImmediatePropagation();
         evt.PreventDefault();
     }
 }
        void BlockEvent(KeyDownEvent evt)
        {
            // Allow copy/paste.
            if (evt.keyCode == KeyCode.C)
            {
                return;
            }

            evt.PreventDefault();
            evt.StopImmediatePropagation();
        }
        void OnEnter(KeyDownEvent evt)
        {
            if (evt.keyCode != KeyCode.Return && evt.keyCode != KeyCode.KeypadEnter)
            {
                return;
            }

            CreateNewSelector(document.activeStyleSheet);

            evt.PreventDefault();
            evt.StopImmediatePropagation();
        }
        void OnKeyDownEvent(KeyDownEvent evt)
        {
            switch (evt.keyCode)
            {
            case KeyCode.UpArrow:
            {
                SelectBy(-1);
                evt.PreventDefault();
                evt.StopImmediatePropagation();
                break;
            }

            case KeyCode.DownArrow:
            {
                SelectBy(1);
                evt.PreventDefault();
                evt.StopImmediatePropagation();
                break;
            }
            }
        }
示例#8
0
        private void OnKeyDown(KeyDownEvent evt, SearchSuggest ss)
        {
            if (ss.PopupVisible)
            {
                return;
            }
            switch (evt.keyCode)
            {
            case KeyCode.Return or KeyCode.KeypadEnter:
                CompleteEdit(true, _nameEditElement.Value, _valuesEditElement.Value);
                break;

            case KeyCode.Escape:
                CompleteEdit(false);
                evt.StopImmediatePropagation();
                break;
            }
        }