Selected text in a segment

Hi,

I would like to select a text in a segment and then perform an operation on it. Does anyone know how I can detect the selected text in a segment?

Best regards,

Henk

Parents
  • Dear Henk,

    You could try this for example:

    EditorController editorController = SdlTradosStudio.Application.GetController<EditorController>();

    Document doc = editorController.ActiveDocument;

    if (doc == null)

                    { return;}

    string selectedText =

      doc.FocusedDocumentContent == FocusedDocumentContent.Source

                      ? doc.Selection.Source.ToString()

    : doc.Selection.Target.ToString();    

    if (!String.IsNullOrEmpty(selectedText))

                    {

    //Run your operation on the selected text

                    }

    I hope this helps.

    regards,

    Laurent

Reply
  • Dear Henk,

    You could try this for example:

    EditorController editorController = SdlTradosStudio.Application.GetController<EditorController>();

    Document doc = editorController.ActiveDocument;

    if (doc == null)

                    { return;}

    string selectedText =

      doc.FocusedDocumentContent == FocusedDocumentContent.Source

                      ? doc.Selection.Source.ToString()

    : doc.Selection.Target.ToString();    

    if (!String.IsNullOrEmpty(selectedText))

                    {

    //Run your operation on the selected text

                    }

    I hope this helps.

    regards,

    Laurent

Children