The scenario:
We have a document with text inside and we are executing the following steps:
Observed: Before releasing the mouse button the cursor position is correct but after releasing it the cursor position is changed to the initial selection end.
In my usage scenario, I want to allow the users to do some specific actions like changing the font or inserting a table row in those restricted areas.
My current implementation is to modify the source code of RadRichTextBox, expose RespectDocumentProtection and RespectNonDeletableRanges, and temporarily set these properties to false before performing modifications in those restricted areas.
Currently, the properties are available in RadDocumentEditor only.
In this feature, the existing text is overridden as the user types on it with the "Insert" key is pressed on the keyboard.
Workaround: Track the state of the Insert key and delete before inserting content using the KeyDown and CommandExecuting events:
private void MainDemoControl_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
{
if (e.KeyboardDevice.IsKeyToggled(Key.Insert))
{
this.isInsertKeyPressed = true;
}
else
{
this.isInsertKeyPressed = false;
}
}
private void radRichTextBox_CommandExecuting(object sender, CommandExecutingEventArgs e)
{
if (e.Command is InsertTextCommand && this.isInsertKeyPressed)
{
this.radRichTextBox.Delete(false);
}
}