This is probably a very naive question. My apologies in advance…
I’m trying to test whether a document has any selected text using the following code:
tell application id "DNtp" set sourceDocument to (the first item of (selection as list)) set citedText to the (selected text of think window 1 as string) if citedText is "" then set citedText to "no text selected" return citedText end tell
If I run this on a PDF with no text selection, then it works as expected – “no text selected”
But if I run it on an RTF file with no text selection, then it returns the whole text file.
Is that expected behaviour?
If so, how do I test for an empty test selection in an rtf file?
[i][The context: I’m trying to adapt korm’s very useful Keyboard Maestro script for citations [url]Make an Annotation with Links, Notes, Tags v2] to differentiate ‘citation’ notes (with selected text) and ordinary notes (without selected text).
I’ve got everything to work as it should with PDFs, but with RTF source documents, it’s returning the entire text when there’s no text selected and that’s not what I want.][/i]