Beispiel #1
0
        protected virtual void OnKeyUp(KeyEventArgs e)
        {
            RadTextBoxControlElement textBox = this.TextBox;

            if (textBox == null || !textBox.IsInValidState(true) || textBox.IsAutoCompleteDropDownOpen)
            {
                return;
            }
            int textLength      = textBox.TextLength;
            int selectionStart  = textBox.SelectionStart;
            int selectionLength = textBox.SelectionLength;

            switch (e.KeyCode)
            {
            case Keys.Left:
                if (selectionLength != 0 || (this.RightToLeft || selectionStart != 0) && (!this.RightToLeft || selectionStart != textLength))
                {
                    break;
                }
                base.OnKeyDown(e);
                break;

            case Keys.Right:
                if (selectionLength != 0 || (this.RightToLeft || selectionStart != textLength) && (!this.RightToLeft || selectionStart != 0))
                {
                    break;
                }
                base.OnKeyDown(e);
                break;
            }
        }
Beispiel #2
0
        public override void OnKeyDown(KeyEventArgs e)
        {
            RadTextBoxControlElement textBox = this.TextBox;

            if (textBox == null || !textBox.IsInValidState(true) || textBox.IsAutoCompleteDropDownOpen)
            {
                return;
            }
            int          selectionStart  = textBox.SelectionStart;
            int          selectionLength = textBox.SelectionLength;
            bool         flag1           = false;
            bool         flag2           = false;
            TextPosition caretPosition   = textBox.Navigator.CaretPosition;

            if (caretPosition != (TextPosition)null)
            {
                LineInfoCollection lines = textBox.ViewElement.Lines;
                flag1 = lines.FirstLine == caretPosition.Line;
                flag2 = lines.LastLine == caretPosition.Line;
            }
            switch (e.KeyCode)
            {
            case Keys.Return:
                if (e.Modifiers == Keys.Control)
                {
                    break;
                }
                base.OnKeyDown(e);
                break;

            case Keys.Up:
                if (this.Multiline && (selectionLength != 0 || !flag1))
                {
                    break;
                }
                base.OnKeyDown(e);
                break;

            case Keys.Down:
                if (this.Multiline && (selectionLength != 0 || !flag2))
                {
                    break;
                }
                base.OnKeyDown(e);
                break;
            }
        }