I am trying to track when a file is dropped on a PDFView to be able to get the attributes of the document and display them in the user interface.
I can initiate the drag operation with : myPdfView’s setAllowsDragging_(true). This works in that the document is displayed in the view, but I cannot track when the change of the document happens in the view.
Is there a way to implement the drag and drop methods for a PDFView as for NSWindow, NSTableView …
I also tried the notification center where I find a PDFViewDocumentChangedNotification but I cannot get it to work.
This worked for me to get the notification when I dropped a pdf on the view:
on applicationWillFinishLaunching_(aNotification)
pdfView's setAllowsDragging_(true)
pdfView's setDelegate_(me)
set noter to current application's NSNotificationCenter's defaultCenter()
noter's addObserver_selector_name_object_(me,"pdfChange:",current application's PDFViewDocumentChangedNotification,missing value)
end applicationWillFinishLaunching_
on pdfChange_(sender)
log "document changed"
end
Actually it’s not too late, you can get it from the PDFView’s |document|()'s documentURL(). It took me a while to figure out why I couldn’t get this to work in ASOC at first (it worked in obj-c), because I was being lazy and using the crappy Xcode 4 editor, so I didn’t notice that “document()” needed pipes. Better to use your AppleScriptObjC Explorer where those things are obvious.