How to select/highlight target segment text base on comment

I have Custom View where  list of comments of selected segment will be displayed. Now want to achieve is, once comment selected in custom view then it should select/highlight respective text in segment.

Can anyone do needful?

See snap shot. Its in context of Comment Window in SDL Trados Studio, need to implement same feature for text selection.

Screenshot of SDL Trados Studio interface showing the Comment Window with a list of comments. A red box highlights a selected comment and red arrows point to the corresponding text in the segment editor, indicating the feature to select and highlight text.



Generated Image Alt-Text
[edited by: Trados AI at 1:12 PM (GMT 0) on 5 Mar 2024]
Parents Reply
  • Hi Harshad,

    You can't subscribe to an event through the Integration API; but you can potentially listen for changes and intuitively deduct when comments are added/removed.

    Start by subscribing to the ActiveDocumentChanged event on the EditorController.

    Then subscribe to the ActiveSegmentChanged, ContentChanged events when active document changes.

    Manage a collection on the document to identify the list of comments associated with each of the segmentPairs (read when the document is loaded).  Call this CollectionA

    Note: when you add a comment to the segment, the content changed event is fired. Understanding this, you would only need to get the current list of comments for the active segment pair and then compare it against a comments for the segment mentioned in CollectionA that you are managing on the document.

    private void ActiveDocument_ContentChanged(object sender, DocumentContentEventArgs e)
    {

    [...]

         var segmentSourceComments = segmentPair.Source.GetComments();
         var segmentTargetComments = segmentPair.Target.GetComments();
         var segmentParagraphComments = segmentPair.GetParagraphUnitProperties().Comments;

        // Compare list of comments listed here against what was initially read in CollectionA
        // Identify what was added or removed
        // if different, do something!
        // update CollectionA with the new list of comments for the SegmentPair (if different)

    [...]

    }

    similarly, perform same check in the ActiveSegmentChanged; to cover cases where the content structure of the segment didn't change; I'd need to check but might be that if the scope of the comment is at the paragraph level, then the ContentChanged is not fired!

Children