Keyboard interface wrong

4 posts, 1 answers
  1. Jason
    Jason avatar
    18 posts
    Member since:
    Aug 2014

    Posted 17 Aug 2014 Link to this post

    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?
  2. Answer
    Dimitar
    Admin
    Dimitar avatar
    1408 posts

    Posted 20 Aug 2014 Link to this post

    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.
     
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Jason
    Jason avatar
    18 posts
    Member since:
    Aug 2014

    Posted 20 Aug 2014 Link to this post

    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.  
  5. Dimitar
    Admin
    Dimitar avatar
    1408 posts

    Posted 22 Aug 2014 Link to this post

    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.
     
Back to Top