Backspace key does not properly invalidate editor

5 posts, 0 answers
  1. Chris Ward
    Chris Ward avatar
    52 posts
    Member since:
    Jan 2010

    Posted 13 May 2015 Link to this post

    Bug: 

    When I use the backspace key in RadRichTextEditor it causes visual artifacts to be left behind. It doesn't matter if I am deleting a selection or just one character. The artifacts disappear as soon as I press or click anything else (including pressing backspace again, on the KeyDown event).

    See attached image.

    Solution:

    The control (or affected visual area) should be invalidated when the backspace key is pressed.

    Hack:

    I was able to eliminate all artifacts by overriding the KeyDown event and forcing the control to invalidate whenever the backspace key is pressed:

    protected override void OnKeyDown(System.Windows.Forms.KeyEventArgs e)
    {
        base.OnKeyDown(e);
     
        if (e.KeyCode == System.Windows.Forms.Keys.Back)
        {
            Invalidate();
        }
    }

  2. Dimitar
    Admin
    Dimitar avatar
    1408 posts

    Posted 14 May 2015 Link to this post

    Hello Chris,

    Thank you for writing.

    This is a known issue and it is already logged in our Feedback Portal. You can track the item for status changes and add your vote for it here.

    To workaround this you can refresh the control after a specific interval:
    Timer timer;
     
    public RadForm1()
    {
        InitializeComponent();        
        radRichTextEditor1.CommandExecuted += radRichTextEditor1_CommandExecuted;
        timer = new Timer();
        timer.Interval = 50;
        timer.Tick += timer_Tick;
    }
     
    void timer_Tick(object sender, EventArgs e)
    {
        this.radRichTextEditor1.RichTextBoxElement.ElementTree.Control.Refresh();
        timer.Stop();
    }
     
    void radRichTextEditor1_CommandExecuted(object sender, Telerik.WinForms.Documents.RichTextBoxCommands.CommandExecutedEventArgs e)
    {
        if (e.Command is DeleteCommand)
        {
            if (this.radRichTextEditor1.RichTextBoxElement.ElementTree != null && this.radRichTextEditor1.RichTextBoxElement.ElementTree.Control != null)
            {
                timer.Start();
            }
        }
    }

    Do not hesitate to contact us if you have other questions.

    Regards,
    Dimitar
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Chris Ward
    Chris Ward avatar
    52 posts
    Member since:
    Jan 2010

    Posted 14 May 2015 Link to this post

    Thanks for that.

     Do you have an equivalent fix for the mouse wheel scrolling bug? If I use the mouse wheel to scroll up or down in a document that is taller than the RadRichTextEditor control, it scrolls "too far", i.e., past the beginning or end of the document.

     In the attached screenshot, "Today:" is the first line of my document. After scrolling up with the mouse wheel, I see a load of unwanted whitespace at the top. When I go to select it, the scroll "snaps" back to having "Today:" at the top of the editor.

     

  5. Dimitar
    Admin
    Dimitar avatar
    1408 posts

    Posted 15 May 2015 Link to this post

    Hello Chris,

    Thank you for writing back.

    I was able to reproduce this issue as well. You can track the item for status changes and add your vote for it here.

    To workaround it you can use the MouseWheel event:
    void radRichTextEditor1_MouseWheel(object sender, MouseEventArgs e)
    {
        Telerik.WinControls.RichTextEditor.UI.DocumentPresenterBase presenter =
            this.radRichTextEditor1.RichTextBoxElement.ActiveEditorPresenter as Telerik.WinControls.RichTextEditor.UI.DocumentPresenterBase;
        presenter.GetType().GetProperty("VerticalScrollOffset", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)
            .SetValue(presenter, this.radRichTextEditor1.RichTextBoxElement.VerticalScrollBar.Value, null);
    }

    Your Telerik Points have been updated for this report.

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

    Regards,
    Dimitar
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  6. Chris Ward
    Chris Ward avatar
    52 posts
    Member since:
    Jan 2010

    Posted 15 May 2015 in reply to Dimitar Link to this post

    Excellent, that worked brilliantly! Thank you, Dimitar.
Back to Top
UI for WinForms is Visual Studio 2017 Ready