This is a migrated thread and some comments may be shown as answers.

Keyboard interface wrong

3 Answers 12 Views
RichTextBox (obsolete as of Q3 2014 SP1)
This is a migrated thread and some comments may be shown as answers.
Jason
Top achievements
Rank 1
Jason asked on 18 Aug 2014, 12:45 AM
When using Ctrl+Left to navigate the rich text, when the cursor is at the end of a word, or inside a word, Ctrl+Left goes to the start of the previous word.  It should go to the start of the current word.

Is there a work-around for this?  Can it be fixed?

3 Answers, 1 is accepted

Sort by
0
Accepted
Dimitar
Telerik team
answered on 20 Aug 2014, 12:59 PM
Hi Jason,

Thank you for writing.

I was able to reproduce this issue and I have logged it in our Feedback Portal. You can track the item for status changes and add your vote for it here.

To workaround this you create a custom input behavior and handle the left key manually:
public class CustomInputBehavior : InputBehavior
{
    public CustomInputBehavior(DocumentView view) : base(view)
    {
    }
 
    protected override bool ProcessLeftKey(KeyEventArgs e)
    {
        RadDocument document = this.DocumentView.Document;
        if ((Control.ModifierKeys & Keys.Control) == Keys.Control)
        {
            string pos = document.CaretPosition.ToString();
            int posInWord = Convert.ToInt32(pos.Substring(pos.IndexOf('@') + 1, 1));
            if (posInWord > 0)
            {
                document.CaretPosition.MoveToCurrentWordStart();
            }
            else
            {
                document.CaretPosition.MoveToPreviousWordStart();
            }
           
            return true;
        }
        return base.ProcessLeftKey(e);
    }
}

The behavior can be changed as follows:
this.radRichTextBox1.DocumentView.InputBehavior =
new CustomInputBehavior(this.radRichTextBox1.DocumentView);

Your Telerik Points have been updated for this report.

Should you have any other questions do not hesitate to ask.

Regards,
Dimitar
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Jason
Top achievements
Rank 1
answered on 21 Aug 2014, 12:37 AM
Thanks Dimitar.
I've updated the code to also handle the caret at the end of a word or at the end of a paragraph:

if (posInWord > 0 || pos == "\" \"@0" || pos == "\"ΒΆ\"@0")
{
    document.CaretPosition.MoveToCurrentWordStart();
}

The solution works, but the Caret doesn't move immediately, as it does without the custom input behavior.  
0
Dimitar
Telerik team
answered on 22 Aug 2014, 01:34 PM
Hi Jason,

Thank you for writing back.

Please note that this is just a workaround and in this case the functionality can be slower than normal. Nevertheless if you have any questions, please do not hesitate to contact us.
 
Regards,
Dimitar
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
RichTextBox (obsolete as of Q3 2014 SP1)
Asked by
Jason
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Jason
Top achievements
Rank 1
Share this question
or