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
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
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
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