I’m exhausted trying to figure out how to drop a .doc file into a text view. Ican’t even write a droplet to read the text from the file.
I just want to drag a .doc onto my text view and see its contents. I swear I’m not lazy, I just have so many other parts of this app to develop, and I’ve already wasted a day and a half on this. Can anyone help, or just get me started?
on drop theObject drag info dragInfo
set dataTypes to types of pasteboard of dragInfo
if "file names" is in dataTypes then
set preferred type of pasteboard of dragInfo to "file names"
set thePaths to contents of pasteboard of dragInfo
if (count of thePaths) is 1 then
-- add test for .doc file extension here
if ((call method "loadContentsFromFile:" of theObject with parameter (item 1 of thePaths as string)) ≠1) then
display dialog "loading the document failed"
end if
end if
end if
end drop
and add the method for loading Word/RTF/text etc. in an NSTextView (just add this two files in your project):