Approved
Last Updated: 21 Aug 2018 15:13 by ADMIN
ADMIN
Tanya
Created on: 17 Aug 2018 18:12
Category: RichTextBox
Type: Feature Request
1
RichTextBox: Shift+Up(Down) should create selection to the start(end) of document when the caret position is on the first(last) line
When pressing Shift+Up(Down) should create a selection to the start(end) of the document when the caret position is on the first(last) line. Currently, in this case, a selection is not created.

Such behavior can be achieved using the following approach:

        private void RadRichTextBox_CommandExecuting(object sender, CommandExecutingEventArgs e)
        {
            if (e.Command is MoveCaretCommand && System.Windows.Input.Keyboard.Modifiers == ModifierKeys.Shift)
            {
                var command = e.Command as MoveCaretCommand;
                MoveCaretDirections direction = (MoveCaretDirections)e.CommandParameter;
                if (direction == MoveCaretDirections.Up)
                {
                    var positionOnFirstLine = new DocumentPosition(this.radRichTextBox.Document);
                    positionOnFirstLine.MoveToFirstPositionInDocument();
                    if (this.radRichTextBox.Document.CaretPosition.Location.Y - positionOnFirstLine.Location.Y < 1)
                    {
                        this.radRichTextBox.Document.CaretPosition.MoveToPosition(positionOnFirstLine);
                        e.Cancel = true;
                    }
                }
                else if (direction == MoveCaretDirections.Down)
                {
                    var positionOnLastLine = new DocumentPosition(this.radRichTextBox.Document);
                    positionOnLastLine.MoveToLastPositionInDocument();
                    if (positionOnLastLine.Location.Y - this.radRichTextBox.Document.CaretPosition.Location.Y < 1)
                    {
                        this.radRichTextBox.Document.CaretPosition.MoveToPosition(positionOnLastLine);
                        e.Cancel = true;
                    }
                }
            }
        }
(Total attached files size should be smaller than 20mb. Allowed extensions: .zip, .rar, .jpg, .png, .gif)
0 comments