Setting Selection Range does not work for Xamarin RichTextEditor

1 Answer 83 Views
RichTextEditor
Xu
Top achievements
Rank 1
Xu asked on 27 Aug 2021, 01:18 AM

Hello Guys,

According to the meta data,

The Xamarin RichTextEditor's SelectionRange object is settable


 //
// Description:
//     Gets or sets the selection range of the text in the Telerik.XamarinForms.RichTextEditor.RadRichTextEditor.
public RichTextSelectionRange SelectionRange { get; set; }

So I tried to "set" the SelectionRange by code:


 public void SetSelecionRange(int startIndex, int endIndex)
        {
            EditBox.SelectionRange = new RichTextSelectionRange(startIndex, endIndex);
        }

But actually nothing happens, and I am not sure the how the start and end index of the selection is configured, perhaps based on the html code index? or plain text index?

I am not able to find the guide for setting selection range.

 

Please offer some help.

1 Answer, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 31 Aug 2021, 09:39 AM

Hello Xu,

Indeed, SelectionRange property is settable  - the selection can be defined only when RichTextEditor is in focus (not initially).   Please try tapping inside the editing area and then call the SetSecionRange method - it should work in this way. StartIndex and EndIndex are just the consecutive index of the first and last symbol included in the text selection.

Other than that, we have the following feature request regarding focusing the RichTextEditor control:

RichTextEditor: Provide an option to auto-focus the control and display the keyboard when in edit mode

Let me know if I can help with anything else.

Regards,
Yana
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Xu
Top achievements
Rank 1
commented on 02 Sep 2021, 08:27 AM

Hello Yana, Thank you for another answer to my question.

 

I tried to set the range after tapping the editor. 


 public void SetSelecionRange(int startIndex, int endIndex)
 {
            EditBox.SelectionRange = new RichTextSelectionRange(startIndex, endIndex); 
 }

But still not working, just nothing happens after calling the method as you can tell from the attached video.

The video from OneDrive

Did I miss something?

 

 

 

The control version is Telerik.XamarinForms.RichTextEditor, Version=2021.1.325.480 

Yana
Telerik team
commented on 07 Sep 2021, 08:13 AM

I noticed in the video the SelectionRange is called from some kind of popup. Please send me some sample code showing exactly the implementation you have as on my side the selection is executed without a problem.
Tags
RichTextEditor
Asked by
Xu
Top achievements
Rank 1
Answers by
Yana
Telerik team
Share this question
or