how to change mouse cursor of Span ?

2 posts, 0 answers
  1. Sopan
    Sopan avatar
    34 posts
    Member since:
    May 2012

    Posted 31 Jul 2013 Link to this post


    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?

    Sopan Vaidya
  2. Iva Toteva
    Iva Toteva avatar
    1319 posts

    Posted 02 Aug 2013 Link to this post

    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.

    Iva Toteva
    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 >>
  3. DevCraft R3 2016 release webinar banner
Back to Top