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

Insert Hyperlink Dialog

3 Answers 159 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Stephen
Top achievements
Rank 1
Stephen asked on 21 Jul 2010, 11:45 AM
Hi,

I am trying to get the insert hyperlink dialog to show but I have so far been unsuccessful.

I have a button with a Datacontext set to the RichTextBox and have the following command binding for it :

Command

 

 

="{Binding Path=ShowInsertHyperlinkDialogCommand}"

 


Nothing was happening so I did a bit of digging in the API and found that the RichTextBox had an InsertHyperlinkDialog property that was null.  So I created my own implementation of IInsertHyperlinkDialog and set the InsertHyperlinkDialog property to an instance of that dialog.

I have two issues.  The first issue is that the dialog is still not showing.  My second issue is that I do not know what the custom ShowDialog method is meant to do.  It seems a little strange as it takes in the address and text beforehand...

How is one meant to implement these dialogs?

Thanks,

Stephen

3 Answers, 1 is accepted

Sort by
0
Stephen
Top achievements
Rank 1
answered on 21 Jul 2010, 11:55 AM
Woopsie, had a bad breakpoint so I didn't see the call getting through to my implementation, so it looks like thats working now. 

Looks like I just need to either call the insertCallback or cancelCallback.  What are the text and address arguments for?
0
Accepted
Alex
Telerik team
answered on 23 Jul 2010, 09:57 AM
Hi Stephen,

The help articles for the new features of the RadRichTextBox are currently a little out-of-date. We are sorry for the inconvenience.

The default implementations of all dialog windows (like the hyperlink dialog) live in a separate assembly - Telerik.Windows.Controls.RichTextBoxUI. If you want to use them, all you have to do is to add a reference to this assembly in your project. All dialogs will be automatically loaded in the RadRichTextBox using MEF. We will have a blog post on this topic very soon explaining how  all of this comes together.


However, you seem to be doing really well with implementing your own hyper-link dialog. Here are some tips if you want to continue with this endeavor. Whenever you execute the ShowInsertHyperlinkDialogCommand or call the ShowInsertHyperlinkDialog method of the RadRichTextBox the ShowDialog of the currently loaded in the rich text box ShowInsertHyperlinkDialog will be called.  The RadRichTextBox will pass the currently selected text to the ShowDialog in the text parameter.

If there is nothing selected  whole word or link under the current caret position will be selected. In the address parameter you will get the URL of the currently selected hyperlink if that is the case. This way you can alter existing hyperlink or turn selected spans into hyperlink. The cancelCallback should be called when closing the dialog, when no link is inserted,  to restore the previous caret position and selection state. Finally insertHyperlinkCallback is used to actually insert a hyper-link into the document.


I hope this clarification were useful. Let us know if you need any further help.


All the best,
Alex
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Stephen
Top achievements
Rank 1
answered on 25 Jul 2010, 11:23 PM
Thanks Alex,

That was the answer I was looking for.  All done and dusted now.
Tags
RichTextBox
Asked by
Stephen
Top achievements
Rank 1
Answers by
Stephen
Top achievements
Rank 1
Alex
Telerik team
Share this question
or