コード例 #1
0
        public void HandleKeyboard(bool requireKeyboardFocus)
        {
            //if (Event.current.GetTypeForControl (m_KeyboardControlID) != EventType.keyDown)
            if (Event.current.type != EventType.keyDown)
            {
                return;
            }

            if (requireKeyboardFocus && (GUIUtility.keyboardControl != m_KeyboardControlID || !GUI.enabled))
            {
                return;
            }

            if (HandleKeyEvent(Event.current))
            {
                Event.current.Use();
                return;
            }
            ResetMoveVerticallyTargetColumn();

            var c = Event.current.character;

            if (!_font.HasCharacter(c) && c != '\t' && c != '\n')
            {
                Event.current.Use();
                return;
            }

            if (HasSelection())
            {
                DeleteSelection();
            }

            _document.Insert(_document.CurrentLine.Start + Caret.Column, c.ToString(CultureInfo.InvariantCulture));
            if (c == '\n')
            {
                Caret.SetPosition(Caret.Row + 1, 0);
            }
            else
            {
                Caret.MoveRight();
            }

            Event.current.Use();

            // On tab we auto cycle to next guicontrol here we ensure to grab it back
            if (c == '\t')
            {
                m_GrabKeyboardControl = true;
            }
        }
コード例 #2
0
 public void MoveRightWhenColumnIsNotLast()
 {
     GenericCaretTest(0, 1, () => _caret.MoveRight(), 0, 2);
 }