Hi,
I am trying to save data from a textView using Shane Stanley’s showSavePane: from Myriad Helper 20.2. The code works when using appleScript’s choose file name, however, it doesn’t open the dropdown sheet when I put the following code:
Property parent : class “NSObject”
property theWindow : missing value
property textView : missing value
on showSavePanel:sender
set thePanel to current application's NSSavePanel's makeSaveAt:(path to desktop folder) |types|:{"txt"} |name|:"Some output" prompt:"Save Some Information Text:" title:"My Save Title"
set theText to textView's textStorage()'s |string|() as text ## this is in NSUTF8StringEncoding: format
set fileManager to current application's NSFileManager's defaultManager()
if (fileManager's fileExistsAtPath:thePanel) as boolean = false then
set theResult to fileManager's createFileAtPath:thePanel |contents|:theText attributes:(missing value)
end if
thePanel's showOver:theWindow calling:{"saveSheetDone:", me}
end showSavePanel:
on saveSheetDone:theResult -- called when panel closed
if theResult = missing value then
-- cancel button
log "Cancel pressed"
else
log theResult -- path to file
end if
end saveSheetDone:
Could I get some assistance to get the above working. Just a note here, I have not been doing any ASOC scripting for over two years so I have forgotten quite a bit.
Thanks,
t.