Completed
Last Updated: 03 Jun 2015 12:09 by ADMIN
ADMIN
Ivan Todorov
Created on: 10 Apr 2015 11:30
Category: RichTextEditor
Type: Bug Report
0
FIX. RadRichTextEditor - exception when you try to input a character and the selection covers multiple sections.
If you populate the document with more than one section as shown below:

Section Section1 = radRichTextEditor.Document.Sections(0);
Paragraph Paragraph1 = new Paragraph(); 
Span Span1 = new Span("Thank you for choosing Telerik");
Section1.Blocks.Add(Paragraph1);

Section Section2 = new Section();
Paragraph Paragraph2 = new Paragraph();
Paragraph2.Inlines.Add(image);
Section2.Blocks.Add(Paragraph2);
radRichTextEditor..Document.Sections.Add(Section2);

then mark as selected the space after the first span, then try to type a character, a NullReferenceException will be thrown.

WORKAROUND:

class MyInputBehavior : RichTextEditor.RichTextEditorInputBehavior
{
	public MyInputBehavior(RadRichTextBox editor) : base(editor) { }

	public override void InsertText(string text)
	{
		if (this.RichTextBox.IsReadOnly) {
			return;
		}

		Telerik.WinForms.Documents.UI.CaretTextInputHandler handler = null;

		DocumentPrintLayoutPresenter printLayout = this.RichTextBox.ActiveEditorPresenter as DocumentPrintLayoutPresenter;

		if (printLayout != null) {
			DocumentPagePresenter pagePresenter = printLayout.GetFocusedPresenter();
			if (pagePresenter == null) {
				pagePresenter = ((Canvas)printLayout.Content).Children[0] as DocumentPagePresenter;
			}
			handler = pagePresenter != null ? pagePresenter.CaretTextInputHandler : null;
		}

		DocumentWebLayoutPresenter webLayout = this.RichTextBox.ActiveEditorPresenter as DocumentWebLayoutPresenter;

		if (webLayout != null) {
			handler = webLayout.CaretTextInputHandler;
		}

		if (handler != null) {
			handler.HandleTextInsertedWithoutIme(this.RichTextBox.ActiveEditor.Document, text);
		}
	}
}

radRichTextEditor.InputHandler = New MyInputBehavior(radRichTextEditor.RichTextBoxElement)
0 comments