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