Пример #1
0
        public void Update()
        {
            ToggleWindowByKeys();

            if (window_.isOpen)
            {
                if (inputField.isFocused)
                {
                    keyEvent_.Check();
                }
                else
                {
                    keyEvent_.Clear();
                }

                if (window_.hasCompletion && KeyUtil.Enter())
                {
                    window_.DoCompletion();
                }
                else if (IsEnterPressing())
                {
                    window_.OnSubmit(inputField.text);
                }
            }
        }
Пример #2
0
        private bool CheckKey(EventInfo info)
        {
            bool option = false;

            switch (info.option)
            {
            case Option.None: option = true;                     break;

            case Option.Ctrl: option = KeyUtil.Control();        break;

            case Option.Shift: option = KeyUtil.Shift();          break;

            case Option.Alt: option = KeyUtil.Alt();            break;

            case Option.CtrlOrShift: option = KeyUtil.ControlOrShift(); break;
            }

            if (Input.GetKey(info.key) && option)
            {
                ++info.counter;
            }
            else
            {
                info.counter = 0;
            }

            return
                (info.counter == 1 || (
                     (info.counter >= holdInputStartDelay) &&
                     (info.counter % holdInputFrameInterval == 0)));
        }
Пример #3
0
 public bool IsEnterPressing()
 {
     if (!inputField.multiLine)
     {
         return(KeyUtil.Enter());
     }
     else
     {
         return((KeyUtil.Control() || KeyUtil.Shift()) && KeyUtil.Enter());
     }
 }
Пример #4
0
        // To change default behavior and to support multiple gui,
        // override InputFiled method here.
        public override void OnUpdateSelected(BaseEventData eventData)
        {
            if (!isFocused)
            {
                return;
            }

            // To support multiple gui, set the window that this input filed is belonging to
            // as the current active window.
            Window.selected = parentWindow;

            bool consumedEvent = false;
            var  e             = new Event();

            while (Event.PopEvent(e))
            {
                if (e.rawType == EventType.KeyDown)
                {
                    consumedEvent = true;

                    // Skip because these keys are used for histroy selection in single-line mode
                    // and for move cursor manually in multi-line mode.
                    switch (e.keyCode)
                    {
                    case KeyCode.UpArrow:
                    case KeyCode.DownArrow:
                        continue;
                    }

                    // Skip if completion view is open.
                    if (parentWindow.hasCompletion)
                    {
                        if (e.keyCode == KeyCode.Tab || KeyUtil.Enter())
                        {
                            break;
                        }
                    }

                    var shouldContinue = KeyPressed(e);

                    // Prevent finish.
                    // Command submission and cancel are observed and handled in Core.
                    switch (e.keyCode)
                    {
                    case KeyCode.Return:
                    case KeyCode.KeypadEnter:
                    case KeyCode.Escape:
                        shouldContinue = EditState.Continue;
                        break;
                    }

                    if (shouldContinue == EditState.Finish)
                    {
                        DeactivateInputField();
                        break;
                    }
                }
            }

            if (consumedEvent)
            {
                UpdateLabel();
            }

            eventData.Use();
        }