DocumentPosition.SetPosition(PointF )is not working properly

2 posts, 0 answers
  1. Neelima
    Neelima avatar
    1 posts
    Member since:
    Nov 2014

    Posted 10 Nov 2014 Link to this post

    I am trying to capture the mouse location(hover) and trying to display a tooltip based on the text that is highlited.
    For that i am doing this

              var p = e.GetPosition(null);            
               DocumentPosition position = new DocumentPosition(this.ArcEditor.Document);           
              var pBox = position.GetCurrentInlineBox(); 

    But my position is always pointing to the same location. My mouse coordinates(p) are changing with the mouse move but documnet position is not set properly.

    Can someone help me on this.

    Thanks in advance.
  2. Todor
    Todor avatar
    168 posts

    Posted 12 Nov 2014 Link to this post

    Hello Neelima,

    Basing on the provided code, you can attach to the RadRichTextBox's MouseMove event and the handler should looks like as follows:
    private void RadRichTextBox_MouseMove(object sender, MouseEventArgs e)
        RadRichTextBox richTextBox = (RadRichTextBox)sender;
        Point point = e.GetPosition(richTextBox);
        point.X /= richTextBox.ScaleFactor.Width;
        point.Y /= richTextBox.ScaleFactor.Height;
        DocumentPosition position = new DocumentPosition(richTextBox.Document);
        var inlineLayoutBox = position.GetCurrentInlineBox();
        // ...

    Please, note that the provided code above will work when RadRichTextBox is in Flow or FlowNoWrap LayoutMode. For Paged mode, you should implement different logic. 

    I'm not sure what is your final goal you should achieve, but instead of showing a tooltip, you can implement your own custom UI layer and visualize the necessary information there.
    You can check our Customize Presentation demo or this SDK demo on that matter. You can read more about custom UI layers in this help article.

    I hope this helps.


    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

  3. DevCraft banner
Back to Top