Programmatically highlighting text

2 posts, 0 answers
  1. Chris
    Chris avatar
    12 posts
    Member since:
    Sep 2012

    Posted 19 Jan 2011 Link to this post

    I have a question concerning programmatically highlighting text and then highlightlighting that same text again. Highlighting text creates a span. If you highlight the same color and the same text the span is not modified. If you highlight with a different color a new span is created. I am trying to implement a recommended change framework I will call it. Everytime a recommended change is recommended they are forced to select text which gets highlighted. An admin of sorts will come in and approve or reject these changes and the text will be changed or not changed and the highlighting will be removed. Now the problem occurs when two people come in and recommend a change for the same text. One issue is that the highlight color has to change for a new span to be created. The next issue is the fact that you cannot have nested spans. Say three people all suggest changes to three parts of the same text using a different highlighting color each time. You now have atleast 3 spans. Now when an admin aproves or rejects a change this becomes a programmatic nightmare. Is there any other way to implement this that would be easier? 
  2. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 25 Jan 2011 Link to this post

    Hi Chris,

    Your scenario as I understand it would really be quite difficult to implement in RadRichTextBox. We do not support tracking changes to the document in the first place. In addition, there will be indeterministic cases with tracking multiple users' changes to the same pieces of the document.
    As for the spans splitting and merging - spans are split when different style settings are applied to different parts of a span and are merged when adjacent spans's style properties are set to the same values. We have not met the need to have nested spans in the document and I am not quite sure how that will help with your scenario.
    You can try using document positions that track changes to the document (they are created using the two-parameter constructor of the DocumentPosition class with the second parameter set to true) in order to keep the beginning and end of the text that is modified. These document positions need to be manually disposed of at the end of their use by invoking their Dispose() method, otherwise memory leaks will occur.
    Let us know if we can help further.

    Regards,
    Iva
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
Back to Top