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

[Solved] Is it possible to find if CaretPosition (or current span box) is wrapped with HyperlinkRangeStart and HyperlinkRangeEnd tags?

1 Answer 106 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
vaitko
Top achievements
Rank 1
vaitko asked on 30 Aug 2011, 04:01 PM
Hello,

actually what we need - implement custom HyperLinkInsert modal window - we can't use InsertHyperlinkDialog because we need some extra controls in this modal, no need target dropdown and so on...

So we need implement all functionality which works "before" InsertHyperlinkDialog is shown... i mean - if CaretPosition is "on" hyperlink, i need to select all this link and get HyperlinkRangeStart.HyperlinkInfo.NavigateUri... the same with spans which are not wrapped with Hyperlink elements.. if CaretPosition is on some word this word becomes selected..

tried to do this in some diffrent ways... for example by enumerating all hyperlinks in document, selecting these hyperlinks and then comparing each selection range positions  X, Y with CaretPositon X, Y but it doesn't sound good.. also there is some strange behaviour with Y coordinate it has strange values... but its long story.. so the question is: is it possible to implement hyperlinks insert functionality in some easy way without using InsertHyperlinkDialog ?

this.editor.Document.EnumerateChildrenOfType<HyperlinkRangeStart>()
this.editor.Document.Selection.SelectAnnotationRange(hyperlinkRangeStart);

Thanks

1 Answer, 1 is accepted

Sort by
0
Iva Toteva
Telerik team
answered on 02 Sep 2011, 03:13 PM
Hi Gintaras Vaitkus,

In order to implement and wire your own InsertHyperlinkDialog, you don't need to carry out any logic about detecting hyperlinks and selecting them. The only thing you have to do is to create your custom dialog implementing the IInsertHyperlinkDialog interface and mark your implementation with the [CustomInsertHyperlink] attribute. Thus, it will be loaded by MEF and used at the times that our InsertHyperlinkDialog is normally shown.
In case you don't want to rely on MEF for loading the UI, you can directly set the InsertHyperlinkDialog 
property of RadRichTextBox to an instance of your custom UI.

Best wishes,
Iva
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
RichTextBox
Asked by
vaitko
Top achievements
Rank 1
Answers by
Iva Toteva
Telerik team
Share this question
or