Ejemplo n.º 1
0
        private void CommandBarOnOnKeyDown(GUIKeyEventArgs obj)
        {
            switch (obj.Key)
            {
            case Keyboard.Key.Up:
            {
                obj.Handle();
                var current = CommandBar.Text;
                if (!string.IsNullOrWhiteSpace(current) && _currentCommandEdited)
                {
                    // Block up/down if something is typed in.
                    return;
                }

                if (_historyPosition <= 0)
                {
                    return;
                }

                CommandBar.Text = CommandHistory[--_historyPosition];
                break;
            }

            case Keyboard.Key.Down:
            {
                obj.Handle();
                var current = CommandBar.Text;
                if (!string.IsNullOrWhiteSpace(current) && _currentCommandEdited)
                {
                    // Block up/down if something is typed in.
                    return;
                }

                if (++_historyPosition >= CommandHistory.Count)
                {
                    CommandBar.Text  = "";
                    _historyPosition = CommandHistory.Count;
                    return;
                }

                CommandBar.Text = CommandHistory[_historyPosition];
                break;
            }

            case Keyboard.Key.PageDown:
            {
                obj.Handle();
                Output.ScrollToBottom();
                break;
            }
            }
        }
Ejemplo n.º 2
0
        private void InputKeyDown(GUIKeyEventArgs e)
        {
            if (e.Key == Keyboard.Key.Escape)
            {
                Input.ReleaseFocus();
                e.Handle();
                return;
            }

            if (e.Key == Keyboard.Key.Up)
            {
                if (_inputIndex == -1 && _inputHistory.Count != 0)
                {
                    _inputTemp = Input.Text;
                    _inputIndex++;
                }
                else if (_inputIndex + 1 < _inputHistory.Count)
                {
                    _inputIndex++;
                }

                if (_inputIndex != -1)
                {
                    Input.Text = _inputHistory[_inputIndex];
                }

                e.Handle();
                return;
            }

            if (e.Key == Keyboard.Key.Down)
            {
                if (_inputIndex == 0)
                {
                    Input.Text = _inputTemp;
                    _inputTemp = "";
                    _inputIndex--;
                }
                else if (_inputIndex != -1)
                {
                    _inputIndex--;
                    Input.Text = _inputHistory[_inputIndex];
                }

                e.Handle();
                return;
            }
        }
Ejemplo n.º 3
0
        protected internal override void KeyDown(GUIKeyEventArgs args)
        {
            base.KeyDown(args);

            if (!HasKeyboardFocus())
            {
                return;
            }

            if (args.Key == TextHistoryPrev)
            {
                if (HistoryIndex <= 0)
                {
                    return;
                }

                if (HistoryIndex == History.Count)
                {
                    _historyTemp = Text;
                }

                HistoryIndex--;
                Text      = History[HistoryIndex];
                CursorPos = Text.Length;

                args.Handle();
            }
            else if (args.Key == TextHistoryNext)
            {
                if (HistoryIndex >= History.Count)
                {
                    return;
                }

                HistoryIndex++;

                Text = HistoryIndex == History.Count ? _historyTemp : History[HistoryIndex];

                CursorPos = Text.Length;

                args.Handle();
            }
        }