Exemplo n.º 1
0
        private void OnKeyDown(KeyDownEvent e)
        {
            switch (e.keyCode)
            {
            case KeyCode.DownArrow:
                OnDown();
                e.PreventDefault();
                break;

            case KeyCode.UpArrow:
                OnUp();
                e.PreventDefault();
                break;

            case KeyCode.Return:
                seashell.Submit(field);
                // seashell.listIndex = 0;
                break;

            case KeyCode.Tab:
                seashell.Complete(field);
                textField.Focus();
                e.PreventDefault();
                break;
            }
        }
Exemplo n.º 2
0
        void OnKeyDownEvent(KeyDownEvent keyDownEvt)
        {
            if (m_TaggedClip != null)
            {
                if (keyDownEvt.keyCode == KeyCode.F)
                {
                    if (m_SelectionContainer.m_FullClipSelection)
                    {
                        SetTimeRange(0f, m_TaggedClip.DurationInSeconds);
                    }
                    else
                    {
                        var tag = m_SelectionContainer.Tags.FirstOrDefault();
                        if (tag != null)
                        {
                            SetTimeRange(tag.startTime, tag.startTime + tag.duration);
                        }
                        else
                        {
                            SetTimeRange(0f, m_TaggedClip.DurationInSeconds);
                        }
                    }

                    keyDownEvt.StopPropagation();
                    keyDownEvt.PreventDefault();
                }
                else if (keyDownEvt.keyCode == KeyCode.A)
                {
                    SetTimeRange(0f, m_TaggedClip.DurationInSeconds);
                    keyDownEvt.StopPropagation();
                    keyDownEvt.PreventDefault();
                }
            }
        }
Exemplo n.º 3
0
        private void OnKeyDown(KeyDownEvent e)
        {
            if (e.keyCode == KeyCode.R)
            {
                RefreshSession();
            }

            if (e.keyCode == KeyCode.M)
            {
                e.PreventDefault();
                DropDown();
            }

            if (e.keyCode == KeyCode.Space)
            {
                if (e.actionKey)
                {
                    ProcessAll();
                }
                else
                {
                    ProcessSelected();
                }
            }

            if (e.keyCode == KeyCode.P || e.keyCode == KeyCode.RightArrow)
            {
                PingSelected();
            }
        }
Exemplo n.º 4
0
 static void TrapKeys(KeyDownEvent evt)
 {
     if (evt.keyCode == KeyCode.Return || evt.keyCode == KeyCode.KeypadEnter)
     {
         evt.PreventDefault();
     }
 }
Exemplo n.º 5
0
        private void HandleSearchFieldInputs(KeyDownEvent e)
        {
            switch (e.keyCode)
            {
            case KeyCode.DownArrow:
                Scroll(1);
                break;

            case KeyCode.UpArrow:
                Scroll(-1);
                break;

            case KeyCode.PageDown:
                Scroll(Max(1, NumVisibleResults - 1));
                break;

            case KeyCode.PageUp:
                Scroll(-Max(1, NumVisibleResults - 1));
                break;

            case KeyCode.Return:
                Submit(e.modifiers);
                break;

            default:
                return;
            }
            e.PreventDefault();
            e.StopPropagation();
        }
        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();
        }
Exemplo n.º 7
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();
     }
 }
Exemplo n.º 8
0
            void OnNewBuildKeyDown(KeyDownEvent evt)
            {
                if (evt.keyCode == KeyCode.Escape)
                {
                    evt.PreventDefault();
                    evt.StopPropagation();

                    HideNewConfigurationForm(true);
                }
                else if (evt.keyCode == KeyCode.KeypadEnter || evt.keyCode == KeyCode.Return)
                {
                    evt.PreventDefault();
                    evt.StopPropagation();

                    CreateBuildConfigurationWithFormValues();
                }
            }
Exemplo n.º 9
0
        void OnSearchTextFieldKeyDown(KeyDownEvent keyDownEvent)
        {
            // First, check if we cancelled the search.
            if (keyDownEvent.keyCode == KeyCode.Escape)
            {
                CancelSearch();
                return;
            }

            // For some reason the KeyDown event is raised twice when entering a character.
            // As such, we ignore one of the duplicate event.
            // This workaround was recommended by the Editor team. The cause of the issue relates to how IMGUI works
            // and a fix was not in the works at the moment of this writing.
            if (keyDownEvent.character == k_TabCharacter)
            {
                // Prevent switching focus to another visual element.
                keyDownEvent.PreventDefault();

                return;
            }

            // If Tab is pressed, complete the query with the suggested term.
            if (keyDownEvent.keyCode == KeyCode.Tab)
            {
                // Used to prevent the TAB input from executing it's default behavior. We're hijacking it for auto-completion.
                keyDownEvent.PreventDefault();

                if (!string.IsNullOrEmpty(m_SuggestedTerm))
                {
                    SelectAndReplaceCurrentWord();
                    m_AutoCompleteLabel.text = string.Empty;

                    // TODO: Revisit, we shouldn't need to do this here.
                    m_Text = m_SearchTextField.text;

                    Refresh();

                    m_SuggestedTerm = string.Empty;
                }
            }
            else
            {
                SetSelectedElementInResultsList(keyDownEvent);
            }
        }
Exemplo n.º 10
0
 private void KeyPressed(KeyDownEvent evt)
 {
     if (evt.keyCode == KeyCode.KeypadEnter || evt.keyCode == KeyCode.Return)
     {
         AddItem();
         evt.StopPropagation();
         evt.PreventDefault();
     }
 }
        void BlockEvent(KeyDownEvent evt)
        {
            // Allow copy/paste.
            if (evt.keyCode == KeyCode.C)
            {
                return;
            }

            evt.PreventDefault();
            evt.StopImmediatePropagation();
        }
Exemplo n.º 12
0
        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;
            }
            }
        }
        // Key(s) are pressed while the Code area is in focus.
        void OnExecute(KeyDownEvent e)
        {
            // Verify that the Action (Control/Command) and Return (Enter/KeypadEnter) keys were pressed, or that the KeypadEnter was pressed.
            // This 'catches' the first event. This event carries the keyCode(s), but no character information.
            // Here we execute the Python code. The textField itself is left untouched.
            if (e.keyCode == KeyCode.KeypadEnter || (e.actionKey == true && (e.keyCode == KeyCode.Return || e.keyCode == KeyCode.KeypadEnter)))
            {
                m_wereActionEnterPressed = true;
                if (!string.IsNullOrEmpty(GetSelectedCode()))
                {
                    PartialExecute();
                }
                else
                {
                    ExecuteAll();
                    e.PreventDefault();
                }
            }

            // If the right keys were pressed, prevent the KeyDownEvent's default behaviour.
            // This 'catches' the second event. It carries the character information (in this case, "\n"), but has a keyCode of None.
            // Since it is responsible for writing into the textField, we here prevent its default proceedings.
            if (e.keyCode == KeyCode.None && m_wereActionEnterPressed == true)
            {
                e.PreventDefault();
                m_wereActionEnterPressed = false;
            }

            if (IsShortcutPressed(k_undoShortcutBindingID, e))
            {
                PerformUndo();
                return;
            }

            if (IsShortcutPressed(k_redoShortcutBindingID, e))
            {
                PerformRedo();
            }
        }
Exemplo n.º 15
0
        private void HandleSearchFieldInputs(KeyDownEvent e)
        {
            switch (e.keyCode)
            {
            case KeyCode.Escape:
                DoClose();
                break;

            default:
                return;
            }
            e.PreventDefault();
            e.StopPropagation();
        }
Exemplo n.º 16
0
        private void OnKeyDown(KeyDownEvent evt)
        {
            switch (evt.keyCode)
            {
            case KeyCode.Return:
            case KeyCode.KeypadEnter:
                var suggestOption = MatchedSuggestOption[optionList.selectedIndex];
                OnSuggestedSelected?.Invoke(suggestOption);
                textEntry.SetValueWithoutNotify("");
                hasFocus = false;
                UpdateVisibility();
                return;

            case KeyCode.UpArrow:
                evt.PreventDefault();
                if (optionList.selectedIndex > 0)
                {
                    optionList.selectedIndex--;
                }
                break;

            case KeyCode.DownArrow:
                evt.PreventDefault();
                if (optionList.selectedIndex < MatchedSuggestOption.Count - 1)
                {
                    optionList.selectedIndex++;
                }
                break;

            default:
                optionList.selectedIndex = -1;
                break;
            }

            optionList.ScrollToItem(optionList.selectedIndex);
        }