how to get the selected text in a text view?

I’ve searched, but all I found was about getting the contents of the text view. Does anyone know the code for getting the selected text only? I can get the entire contents using (contents of text view…) or (text of text view…). But things like selection, selected text, text selected don’t work for what I need.

tell window "theReader"
			set highlighted_text to (text of text view "textView1" of scroll view "scrollView1")
			say highlighted_text
		end tell

The applescript studio dictionary doesn’t have support for this feature (why, I don’t know :rolleyes: ), so you’ll have to do it with obj-c…

		tell text view "Text" of scroll view "Scroll" of window "Window"
			set Text_Content to content
			set _selectedRange to (call method "selectedRange" of object it)
			set Text_Selection to call method "substringWithRange:" of Text_Content with parameter _selectedRange
			say Text_Selection
		end tell


Jobu, you da man! Works perfect. Thanks for the code because I’m a scripter, not a coder!