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

Backspace key does not properly invalidate editor

4 Answers 198 Views
RichTextEditor
This is a migrated thread and some comments may be shown as answers.
Chris Ward
Top achievements
Rank 1
Chris Ward asked on 13 May 2015, 03:05 PM

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();
    }
}

4 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 14 May 2015, 10:25 AM
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
0
Chris Ward
Top achievements
Rank 1
answered on 14 May 2015, 09:06 PM

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.

 

0
Dimitar
Telerik team
answered on 15 May 2015, 02:17 PM
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
0
Chris Ward
Top achievements
Rank 1
answered on 15 May 2015, 02:27 PM
Excellent, that worked brilliantly! Thank you, Dimitar.
Tags
RichTextEditor
Asked by
Chris Ward
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Chris Ward
Top achievements
Rank 1
Share this question
or