Completed
Last Updated: 07 Feb 2020 10:00 by ADMIN
Release R1 2020 SP1 (LIB 2020.1.210)
Stuart
Created on: 11 Dec 2019 15:19
Category: RichTextEditor
Type: Bug Report
0
RadRichTextEditor: How can I get the RadRichTextEditor to automatically scroll down to follow the cursor when I press return?

I have a RadRichTextEditor. When it contains multiple lines a vertical scroll bar is shown. When I keep writing and press the enter key to insert a carriage return, it starts a new paragraph but the cursor disappears. 

When I press return at the bottom of this control I want the cursor to be kept in sight. See the screenshots I have attached. You can see that after the return you can only see the very top of the cursor, the rest is hidden. You have to actually manually scroll down to get it into view.

When you start typing, this cursor comes into view, but I want it to be in view even if you just press return. Is there a way to get it to do this?

This seems to be the default behavior of this control, as I have created a new application to show this, which doesn't contain any of the formatting which my actual application does.

3 comments
ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 17 Dec 2019 11:11

Hello, Bob,     

Indeed, it is necessary to check whether the cursor is placed at the end and only in this case execute the MoveCaretCommand. Thank you for sharing the updated code in the feedback item.

Should you have further questions please let me know.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Stuart
Posted on: 16 Dec 2019 10:41

Thanks for your help. This work around works well when you are inserting text at the end of the document. But if you insert text at the beginning, or in the middle, then it doesn't behave so well.

I have found that I also need to check whether the cursor is at the document end, and only apply the workaround if it is. So now it looks like this which works well:

Private Sub RadRichTextEditor1_CommandExecuted(sender As Object, e As CommandExecutedEventArgs)

            If TypeOf e.Command Is InsertTextCommand Then
                Application.DoEvents()

                Dim bAtDocEnd As Boolean = RadRichTextEditor1.Document.CaretPosition.IsPositionAtDocumentEnd
                If bAtDocEnd Then
                    Dim command As New MoveCaretCommand(Me.RadRichTextEditor1.RichTextBoxElement)
                    command.Execute(MoveCaretDirections.Down)
                End If
            End If

End Sub

ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 12 Dec 2019 07:44

Hello, Bob, 

Following the provided information, I was able to replicate the undesired scrolling behavior after entering some text and pressing Enter. The behavior is illustrated in the attached gif file. 

I have logged it in our feedback portal by making this thread public. You can track its progress, subscribe for status changes and add your comments on the following link - feedback item.

 

I have also updated your Telerik points.

Currently, the possible solution that I can suggest is to handle the CommandExecuted event and simulate pressing the down arrow to scroll to the bottom. 

    Private Sub RadRichTextEditor_CommandExecuted(sender As Object, e As CommandExecutedEventArgs)
        If TypeOf e.Command Is InsertTextCommand Then
            Application.DoEvents() 
            Dim command As New MoveCaretCommand(Me.RadRichTextEditor1.RichTextBoxElement)
            command.Execute(MoveCaretDirections.Down) 
        End If
    End Sub

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.