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

RadRichTextBox Move and Delete FloatingUIContainer

4 Answers 182 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Marcílio
Top achievements
Rank 1
Marcílio asked on 14 May 2018, 09:13 PM

I'm really need help with this issue.

 

I'm successfully create a custom control and inserted on the RadRichTextBox using the FloatingUIContainer.But now I have tried everything to create a option capable to remove the custom control from the document. But nothing works and I do not have any error or any kind of feedback. The last test was follow below:

radRichTextBox.Document.CaretPosition.MoveToStartOfDocumentElement(FloatingUiElement);
radRichTextBox.Delete(false);

 

Nothing happen when I'm used this command.

I'm need to move the FloatingUIContainer on the page too. But once the element is on the page, I can't move them anymore. Even changing the container horizontal position. Once the scrolling of the document is activated the element returns to the original position.

Somebody can help me?

4 Answers, 1 is accepted

Sort by
0
Boby
Telerik team
answered on 17 May 2018, 01:59 PM
Hi Marcílio,

I just tested the scenarios and I was not able reproduce any of the issues:
For example, when a floating UI is present in the document, invoking 
var firstBlock = radRichTextBox.Document.EnumerateChildrenOfType<FloatingUIContainer>().First();
 
radRichTextBox.Document.CaretPosition.MoveToStartOfDocumentElement(firstBlock);
radRichTextBox.Delete(false);
successfully removes the block.

Could you send us sample applications reproducing the issues, accompanied by specific steps to reproduce them? Specifically for the second issue, how are you trying to move the block, by code or through the UI? What is inside the block and does it handle user events in any way? 

Regards,
Boby
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Marcílio
Top achievements
Rank 1
answered on 17 May 2018, 08:53 PM

Hi Boby,

Thanks for the response. I have found the solution myself. Strangely was happening the following issue: Really when I remove the FloatingUIContainer using the mentioned method, my custom control created an inserted inside the FloatingUIContainer was not removed. The floating block disappear from the document but my custom control continue visible inside it. But I have created an event able to remove my control when this happen anyway.

But taking advantage of your response, now I facing another issue... My objective is create a kind of floating text frame (Like Microsoft Word). And, so far, its working. I was able to insert the floating block, move it over the text (using mouse user interactivity), use adorners to resize de block, etc. But, when I use some keyboard events like delete, backspace, arrows, home key (and some others)... my text frame loses focus and the caret back to the main document. How could I avoid this behavior when my text frame is on focus inside the RadRichTextBox document? Is that possible?

Thank you so much for the help.

Best Regards.

0
Boby
Telerik team
answered on 22 May 2018, 08:55 AM
Hi Marcílio,

You can use PreviewEditorKeyDown to cancel the default keyboard bindings in some cases, for example:
this.radRichTextBox.PreviewEditorKeyDown += (sender, e) =>
{
    if (!this.radRichTextBox.IsKeyboardFocused)
    {
        e.SuppressDefaultAction = true;
    }
};

Another option is to remove the default key bindings for the RadRichTextBox instance, but this would disable the keyboard shortcuts. You can read more for both approaches in the Keyboard Support help article.

Regards,
Boby
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Marcílio
Top achievements
Rank 1
answered on 22 May 2018, 03:41 PM

Hi Boby.

You saved my life. Works perfectly!!
Thanks

Tags
RichTextBox
Asked by
Marcílio
Top achievements
Rank 1
Answers by
Boby
Telerik team
Marcílio
Top achievements
Rank 1
Share this question
or