Ctrl+Backsspace not working in RadRichtextbox

4 posts, 0 answers
  1. chad hartz
    chad hartz avatar
    3 posts
    Member since:
    Sep 2009

    Posted 05 Sep 2014 Link to this post

    In silverlight richtextbox we have the option Ctrl+Backspace to delete the previous typed word.
    But in Telerik Radrichtextbox, we don't have that option.
    Can anyone please help me out of this.
    Is there any option to add Ctrl+Backspace property?
  2. Petya
    Admin
    Petya avatar
    975 posts

    Posted 08 Sep 2014 Link to this post

    Hi Chad,

    At this point this functionality is not available in RadRichTextBox. The feature is already in our product backlog and you can track the public item related to it in the Ideas & Feedback Portal: radrichtextbox ctrl backspace behavior.

    In the meantime you could try implementing this yourself. The Keyboard Support article shows how you can register a custom keyboard binding or subscribe to the PreviewEditorKeyDown event of RadRichTextBox to customize the control's behavior.

    Regards,
    Petya
    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. DevCraft banner
  4. Chad
    Chad avatar
    7 posts
    Member since:
    Jun 2011

    Posted 08 Sep 2014 in reply to Petya Link to this post

    Hi Petya,
    Can you please give an example of code ,in which RadRichtextbox is customised to have the Ctrl+Backspace property.
    Which will be very helpful.

    Thanks
  5. Petya
    Admin
    Petya avatar
    975 posts

    Posted 09 Sep 2014 Link to this post

    Hi Chad,

    Here's a very simple implementation of this:
    void radRichTextBox_PreviewEditorKeyDown(object sender, Telerik.Windows.Documents.PreviewEditorKeyEventArgs e)
    {
        if ((Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift)) && Keyboard.IsKeyDown(Key.Back))
        {
            DocumentPosition end = new DocumentPosition((sender as RadRichTextBox).Document);
            DocumentPosition start = new DocumentPosition((sender as RadRichTextBox).Document);
     
            end.MoveToPosition((sender as RadRichTextBox).Document.CaretPosition);
            start.MoveToPosition(end);
            start.MoveToCurrentWordStart();
     
            (sender as RadRichTextBox).Document.Selection.SetSelectionStart(start);
            (sender as RadRichTextBox).Document.Selection.AddSelectionEnd(end);
     
            (sender as RadRichTextBox).Delete(false);
        }
    }

    Note that you need to take into account the case when the current caret position is in the beginning of a word and handle it. I.e. this would only work for the cases when the caret is at the green marker on the attached picture, but not at the red marker.

    I hope this is useful.

    Regards,
    Petya
    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