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

how to change mouse cursor of Span ?

1 Answer 127 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Sopan
Top achievements
Rank 1
Sopan asked on 31 Jul 2013, 06:55 AM
Hi,

I have a RadRichTextBox, and I have added a span dynamically by change the default cursor style but It not reflected on the added span text.

So how can I change the default cursor style of dynamically added span.

Telerik.Windows.Documents.Model.Span spn = new Telerik.Windows.Documents.Model.Span();
               spn.Text = rnd.Next().ToString()+"[]";
               spn.FontWeight = FontWeights.SemiBold;
               spn.Cursor = Cursors.Hand;
               selectedpara.Children.AddAfter(currentspan, spn);

above code added the span to RadRichTextBox but not change the cursor to Hand


how to do this?

Regards
Sopan Vaidya

1 Answer, 1 is accepted

Sort by
0
Iva Toteva
Telerik team
answered on 02 Aug 2013, 02:28 PM
Hi Sopan,

Document elements such as span are created and removed from the document on the fly depending on the formatting of the text. Since these operations are performed internally by RadDocument in a way that cannot be controlled, setting some properties on Span elements is not that straight-forward.

Furthermore, RadRichTextBox uses UILayers to show different content and provide various user-interaction options. These layers are stacked one on top of the other and the cursor that is shown depends on the order of these layers and the cursor types specified by them.

For example, normally in RadRichTextBox the cursor is IBeam, but there are special cases - the cursor is Hand over hyperlinks and Arrow over an image. This is determined by the layers that are used to show these elements.

What you can try is to implement a custom UI layer as described in this article. You can use Rectangles in the layer and show them over some of the spans that you wish to have a different cursor for, setting the desired cursor type on the rectangles depending on some properties of the span. There is an example of the use of custom layers in GitHub here.


Regards,
Iva Toteva
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
RichTextBox
Asked by
Sopan
Top achievements
Rank 1
Answers by
Iva Toteva
Telerik team
Share this question
or